2023-05-14 22:24:37 +04:00
|
|
|
using CanteenContracts.BindingModels;
|
2023-04-09 19:05:54 +04:00
|
|
|
using CanteenContracts.BusinessLogicsContracts;
|
|
|
|
using CanteenContracts.View;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace CanteenRestApi.Controllers
|
|
|
|
{
|
|
|
|
[Route("api/[controller]/[action]")]
|
|
|
|
[ApiController]
|
|
|
|
public class MainController : ControllerBase
|
|
|
|
{
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
private readonly ICookLogic _cook;
|
|
|
|
private readonly IDishLogic _dish;
|
|
|
|
private readonly IProductLogic _product;
|
2023-05-14 22:24:37 +04:00
|
|
|
private readonly ITablewareLogic _tableware;
|
2023-04-09 19:05:54 +04:00
|
|
|
|
2023-05-14 22:24:37 +04:00
|
|
|
public MainController(ILogger<MainController> logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware)
|
2023-04-09 19:05:54 +04:00
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_cook = cook;
|
|
|
|
_dish = dish;
|
|
|
|
_product = product;
|
2023-05-14 22:24:37 +04:00
|
|
|
_tableware = tableware;
|
2023-04-09 19:05:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
public List<CookViewModel>? GetCookList()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return _cook.ReadList(null);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
2023-05-14 22:24:37 +04:00
|
|
|
[HttpGet]
|
|
|
|
public List<TablewareViewModel>? GetTablewareList()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return _tableware.ReadList(null);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
|
|
public void CreateTableware(TablewareBindingModel model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
_tableware.Create(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
2023-04-09 19:05:54 +04:00
|
|
|
}
|
|
|
|
}
|