diff --git a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs index c0cbff5..695ad24 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs @@ -17,7 +17,7 @@ namespace BeautySalonDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=PRETTYNAME;Initial Catalog=BeautySalonDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=ALYONA\;Initial Catalog=BeautySalonDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs b/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs new file mode 100644 index 0000000..5d359aa --- /dev/null +++ b/BeautySalonView/ClientWebApp/Controllers/EvaluationController.cs @@ -0,0 +1,97 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace WorkerWebApp.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class EvaluationController : Controller + { + private readonly ILogger _logger; + + private readonly IEvaluationLogic _logic; + + public EvaluationController(IEvaluationLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + + [HttpGet] + public EvaluationViewModel? GetEvaluation(int id) + { + try + { + return _logic.ReadElement(new EvaluationSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения оценки"); + throw; + } + } + + [HttpGet] + public List? GetAllEvaluations() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка оценок"); + throw; + } + } + + [HttpPost] + public void CreateEvaluation(EvaluationBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания оценки"); + throw; + } + } + + [HttpPost] + public void UpdateEvaluation(EvaluationBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления оценки"); + throw; + } + } + + [HttpDelete] + public void DeleteEvaluation(EvaluationBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления оценки"); + throw; + } + } + } +} diff --git a/BeautySalonView/ClientWebApp/Controllers/HomeController.cs b/BeautySalonView/ClientWebApp/Controllers/HomeController.cs index f8f8353..1881a07 100644 --- a/BeautySalonView/ClientWebApp/Controllers/HomeController.cs +++ b/BeautySalonView/ClientWebApp/Controllers/HomeController.cs @@ -80,6 +80,7 @@ namespace WorkerWebApp.Controllers Response.Redirect("Privacy"); } + [HttpGet] public IActionResult Enter() { diff --git a/BeautySalonView/ClientWebApp/Controllers/OrderController.cs b/BeautySalonView/ClientWebApp/Controllers/OrderController.cs new file mode 100644 index 0000000..5b08b91 --- /dev/null +++ b/BeautySalonView/ClientWebApp/Controllers/OrderController.cs @@ -0,0 +1,100 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace WorkerWebApp.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class OrderController : Controller + { + private readonly ILogger _logger; + + private readonly IOrderLogic _logic; + + public OrderController(IOrderLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + [HttpGet] + public OrderViewModel? GetOrder(int id) + { + try + { + return _logic.ReadElement(new OrderSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения заказа"); + throw; + } + } + + /// + /// Получение заказов по id пользователя (полный список, кот. будет выводиться) + /// + /// + /// + [HttpGet] + public List? GetOrders(int? workerId) + { + try + { + return _logic.ReadList(new OrderSearchModel { WorkerId = workerId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", workerId); + throw; + } + } + + [HttpPost] + public void CreateOrder(OrderBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + throw; + } + } + [HttpPost] + public void UpdateOrder(OrderBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления заказа"); + throw; + } + } + [HttpDelete] + public void DeleteOrder(OrderBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления заказа"); + throw; + } + } + } +} diff --git a/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs b/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs new file mode 100644 index 0000000..b3b8c23 --- /dev/null +++ b/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs @@ -0,0 +1,114 @@ +using BeautySalonContracts.BindingModels; +using BeautySalonContracts.BusinessLogicContracts; +using BeautySalonContracts.SearchModels; +using BeautySalonContracts.ViewModels; +using WorkerWebApp.Controllers; +using Microsoft.AspNetCore.Mvc; + +namespace WorkerWebApp.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ProcedureController : Controller + { + private readonly ILogger _logger; + + private readonly IProcedureLogic _logic; + + public ProcedureController(IProcedureLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + + [HttpGet] + public ProcedureViewModel? GetProcedure(int id) + { + try + { + return _logic.ReadElement(new ProcedureSearchModel + { + Id = id + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения процедуры"); + throw; + } + } + + [HttpGet] + public List? GetAllProcedures() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка процедур"); + throw; + } + } + + [HttpGet] + public List? GetProcedures(int workerId) + { + try + { + return _logic.ReadList(new ProcedureSearchModel { WorkerId = workerId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка процедур сотрудника id={Id}", workerId); + throw; + } + } + + + [HttpPost] + public void CreateProcedure(ProcedureBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания процедуры"); + throw; + } + } + + [HttpPost] + public void UpdateProcedure(ProcedureBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления процедуры"); + throw; + } + } + + [HttpDelete] + public void DeleteProcedure(ProcedureBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления процедуры"); + throw; + } + } + + } +} diff --git a/BeautySalonView/ClientWebApp/WorkerWebApp.csproj b/BeautySalonView/ClientWebApp/WorkerWebApp.csproj index f11d1ad..25f7ad4 100644 --- a/BeautySalonView/ClientWebApp/WorkerWebApp.csproj +++ b/BeautySalonView/ClientWebApp/WorkerWebApp.csproj @@ -16,8 +16,4 @@ - - - -