using CanteenContracts.BindingModels; 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; private readonly ITablewareLogic _tableware; public MainController(ILogger logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware) { _logger = logger; _cook = cook; _dish = dish; _product = product; _tableware = tableware; } [HttpGet] public List? GetCookList() { try { return _cook.ReadList(null); } catch (Exception ex) { _logger.LogError(ex, "Error during loading list of bouquets"); throw; } } [HttpGet] public List? 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; } } } }