From e08f9b6870fcc65ecc3dcaf49ac7b6eb132a9c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Mon, 27 May 2024 02:47:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=81=D1=82=D0=90=D0=BF=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/Home/Index.cshtml | 12 ++ .../Controllers/CaseController.cs | 74 ++-------- .../Controllers/ClientController.cs | 15 ++ .../Controllers/ExecutorController.cs | 5 +- .../Controllers/GuarantorController.cs | 3 +- .../Controllers/ReportController.cs | 135 ++++++++++++++++++ .../Controllers/VisitController.cs | 6 +- LawCompany/LawCompanyRestApi/Program.cs | 25 ++++ LawCompany/LawCompanyRestApi/appsettings.json | 4 +- 9 files changed, 207 insertions(+), 72 deletions(-) create mode 100644 LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml create mode 100644 LawCompany/LawCompanyRestApi/Controllers/ReportController.cs diff --git a/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml b/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml new file mode 100644 index 0000000..b146c4f --- /dev/null +++ b/LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml @@ -0,0 +1,12 @@ +@{ + ViewData["Title"] = "Home Page"; +} + +
+
+
+

LawCompany

+

Курсовая работа

+
+
+
diff --git a/LawCompany/LawCompanyRestApi/Controllers/CaseController.cs b/LawCompany/LawCompanyRestApi/Controllers/CaseController.cs index 6e8c42f..c13c877 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/CaseController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/CaseController.cs @@ -38,6 +38,20 @@ namespace LawCompanyRestApi.Controllers } } + [HttpGet("{id}")] + public CaseViewModel? GetCase(int id) + { + try + { + return _logic.ReadElement(new CaseSearchModel { Id = id, }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка продуктов"); + throw; + } + } + [HttpPost] public void CreateCase(CaseBindingModel model) { @@ -69,51 +83,6 @@ namespace LawCompanyRestApi.Controllers } - [HttpPost] - public void AnalysisCase(CaseBindingModel model) - { - try - { - //возможно переделаю метод - _logic.CaseAnalysis(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - throw; - } - } - - [HttpPost] - public void HearingCase(CaseBindingModel model) - { - try - { - //возможно переделаю метод - _logic.CaseHearing(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - throw; - } - } - - [HttpPost] - public void CloseCase(CaseBindingModel model) - { - try - { - - _logic.CloseCase(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - throw; - } - } - [HttpPost] public void DeleteCase(CaseBindingModel model) { @@ -129,21 +98,6 @@ namespace LawCompanyRestApi.Controllers } } - [HttpPost] - public void AddClientToCase(Tuple model) - { - try - { - var modelClient = _clientlogic.ReadElement(new ClientSearchModel { Id = model.Item2 }); - if (modelClient != null) _logic.AddClientToCase(model.Item1, modelClient); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания заказа"); - throw; - } - } - [HttpGet] public List? GetClientListToCase(int caseId) { diff --git a/LawCompany/LawCompanyRestApi/Controllers/ClientController.cs b/LawCompany/LawCompanyRestApi/Controllers/ClientController.cs index 595272b..bd87588 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/ClientController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/ClientController.cs @@ -35,6 +35,21 @@ namespace LawCompanyRestApi.Controllers } } + [HttpGet("{id}")] + public ClientViewModel? GetClientById(int id) + { + try + { + return _logic.ReadElement(new ClientSearchModel { Id = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения данных клиента"); + throw; + } + } + + [HttpPost] public void CreateClient(ClientBindingModel model) { diff --git a/LawCompany/LawCompanyRestApi/Controllers/ExecutorController.cs b/LawCompany/LawCompanyRestApi/Controllers/ExecutorController.cs index b98174b..2a9c4ea 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/ExecutorController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/ExecutorController.cs @@ -23,14 +23,13 @@ namespace LawCompanyRestApi.Controllers } [HttpGet] - public ExecutorViewModel? Login(string fio, string email, string password) + public ExecutorViewModel? Login(string login, string password) { try { return _logic.ReadElement(new ExecutorSearchModel { - FIO = fio, - Email = email, + Email = login, Password = password, }); } diff --git a/LawCompany/LawCompanyRestApi/Controllers/GuarantorController.cs b/LawCompany/LawCompanyRestApi/Controllers/GuarantorController.cs index 5b5e2f9..8342e52 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/GuarantorController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/GuarantorController.cs @@ -20,13 +20,12 @@ namespace LawCompanyRestApi.Controllers } [HttpGet] - public GuarantorViewModel? Login(string fio, string login, string password) + public GuarantorViewModel? Login(string login, string password) { try { return _logic.ReadElement(new GuarantorSearchModel { - FIO = fio, Email = login, Password = password }); diff --git a/LawCompany/LawCompanyRestApi/Controllers/ReportController.cs b/LawCompany/LawCompanyRestApi/Controllers/ReportController.cs new file mode 100644 index 0000000..b305fa5 --- /dev/null +++ b/LawCompany/LawCompanyRestApi/Controllers/ReportController.cs @@ -0,0 +1,135 @@ +using LawCompanyBusinessLogic.MailWorker; +using LawCompanyContracts.BindingModels; +using LawCompanyContracts.BusinessLogicContracts; +using Microsoft.AspNetCore.Mvc; + +namespace HotelRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ReportController : Controller + { + private readonly ILogger _logger; + private readonly IReportExecutorLogic _reportExecutorLogic; + private readonly IReportGuarantorLogic _reportGuarantorLogic; + private readonly AbstractMailWorker _mailWorker; + + public ReportController(ILogger logger, IReportExecutorLogic reportExecutorLogic, IReportGuarantorLogic reportGuarantorLogic, AbstractMailWorker mailWorker) + { + _logger = logger; + _reportExecutorLogic = reportExecutorLogic; + _reportGuarantorLogic = reportGuarantorLogic; + _mailWorker = mailWorker; + } + + [HttpPost] + public void CreateExecutorReportToPdfFile(ReportExecutorBindingModel model) + { + try + { + _reportExecutorLogic.SaveClientsToPdfFile(new ReportExecutorBindingModel + { + DateFrom = model.DateFrom, + DateTo = model.DateTo, + ExecutorId = model.ExecutorId, + FileName = "C:\\Reports\\pdffile.pdf", + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + [HttpPost] + public void SendPdfToMail(MailSendInfoBindingModel model) + { + try + { + _mailWorker.MailSendAsync(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отправки письма"); + throw; + } + } + + [HttpPost] + public void CreateExecutorReportToWordFile(ReportExecutorBindingModel model) + { + try + { + _reportExecutorLogic.SaveClientHearingToWordFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + [HttpPost] + public void CreateOrganiserReportToExcelFile(ReportExecutorBindingModel model) + { + try + { + _reportExecutorLogic.SaveClientHearingToExcelFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + /*[HttpPost] + public void CreateHeadwaiterReportToWordFile(ReportHeadwaiterBindingModel model) + { + try + { + _reportHeadwaiterLogic.SaveLunchRoomToWordFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + [HttpPost] + public void CreateHeadwaiterReportToExcelFile(ReportHeadwaiterBindingModel model) + { + try + { + _reportHeadwaiterLogic.SaveLunchRoomToExcelFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + } + + [HttpPost] + public void CreateHeadwaiterReportToPdfFile(ReportHeadwaiterBindingModel model) + { + try + { + _reportHeadwaiterLogic.SaveLunchesToPdfFile(new ReportHeadwaiterBindingModel + { + FileName = "C:\\Reports\\pdffile.pdf", + DateFrom = model.DateFrom, + DateTo = model.DateTo, + HeadwaiterId = model.HeadwaiterId, + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + }*/ + } +} diff --git a/LawCompany/LawCompanyRestApi/Controllers/VisitController.cs b/LawCompany/LawCompanyRestApi/Controllers/VisitController.cs index 79715d5..93c83c2 100644 --- a/LawCompany/LawCompanyRestApi/Controllers/VisitController.cs +++ b/LawCompany/LawCompanyRestApi/Controllers/VisitController.cs @@ -25,9 +25,6 @@ namespace LawCompanyRestApi.Controllers } - - - [HttpGet] public List? GetVisitList(int executorId) { @@ -43,7 +40,7 @@ namespace LawCompanyRestApi.Controllers } } - [HttpGet] + [HttpGet("{id}")] public VisitViewModel? GetVisit(int id) { try @@ -60,7 +57,6 @@ namespace LawCompanyRestApi.Controllers [HttpPost] public void CreateVisit(VisitBindingModel model) { - try { _logic.Create(model); diff --git a/LawCompany/LawCompanyRestApi/Program.cs b/LawCompany/LawCompanyRestApi/Program.cs index 346e70e..4300e1e 100644 --- a/LawCompany/LawCompanyRestApi/Program.cs +++ b/LawCompany/LawCompanyRestApi/Program.cs @@ -1,8 +1,13 @@ +using HotelBusinessLogic.BusinessLogics; using LawCompanyBusinessLogic.BusinessLogics; +using LawCompanyBusinessLogic.OfficePackage.Implements; +using LawCompanyBusinessLogic.OfficePackage; using LawCompanyContracts.BusinessLogicContracts; using LawCompanyContracts.StoragesContracts; using LawCompanyDatabaseImplement.Implements; using Microsoft.OpenApi.Models; +using LawCompanyBusinessLogic.MailWorker; +using LawCompanyContracts.BindingModels; var builder = WebApplication.CreateBuilder(args); @@ -34,6 +39,14 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddSingleton(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle @@ -46,6 +59,18 @@ builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo var app = builder.Build(); +var mailSender = app.Services.GetService(); + +mailSender?.MailConfig(new MailConfigBindingModel +{ + MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty, + MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty, + SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty, + SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()), + PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty, + PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString()) +}); + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/LawCompany/LawCompanyRestApi/appsettings.json b/LawCompany/LawCompanyRestApi/appsettings.json index 5949cde..f1495d8 100644 --- a/LawCompany/LawCompanyRestApi/appsettings.json +++ b/LawCompany/LawCompanyRestApi/appsettings.json @@ -11,6 +11,6 @@ "SmtpClientPort": "587", "PopHost": "pop.gmail.com", "PopPort": "995", - "MailLogin": "lab7yakobchuk@gmail.com", - "MailPassword": "scht ahjt fxmx tdpc" + "MailLogin": "laba46466@gmail.com", + "MailPassword": "iyin rgai wjdh ocmi" }