1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.Filters;
- using ProductionLineMonitor.Core.Dtos;
- using ProductionLineMonitor.Core.Services;
- using ProductionLineMonitor.Web.Filters;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Xml.Linq;
- using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource;
- namespace ProductionLineMonitor.Web.Controllers
- {
- public class RecipeController : BaseController
- {
- private readonly IRecipeService _recipeService;
- public RecipeController(IRecipeService recipeService)
- {
- _recipeService = recipeService;
- }
- [HttpGet("/Recipe")]
- public IActionResult Index()
- {
-
- return View();
- }
- [HttpGet("/Recipe/GetRecipes")]
- public IActionResult GetRecipes(int pageNumber, int pageSize, string keyword)
- {
- pageNumber = pageNumber == 0 ? 1 : pageNumber;
- pageSize = pageSize == 0 ? 10 : pageSize;
- keyword ??= "";
- return Ok(_recipeService.GetPageList(pageNumber, pageSize, keyword));
- }
- [HttpPost("/Recipe/CreateRecipe")]
- public IActionResult CreateRecipe([FromBody] RecipeCreateOrUpdateDto dto)
- {
- return Ok(_recipeService.Create(dto));
- }
- [HttpGet("/Recipe/{id}")]
- public IActionResult GetRecipe([FromRoute] string id)
- {
- return Ok(_recipeService.GetById(id));
- }
- [HttpPost("/Recipe/UpdateRecipe/{id}")]
- public IActionResult UpdateRecipe([FromRoute] string id, [FromBody] RecipeCreateOrUpdateDto dto)
- {
- return Ok(_recipeService.Update(id, dto));
- }
- [HttpPost("/Recipe/DeleteRecipe/{id}")]
- public IActionResult DeleteRecipe([FromRoute] string id)
- {
- return Ok(_recipeService.Delete(id));
- }
- }
- }
|