РестАпи для Исполнителя
This commit is contained in:
parent
8c84e64cb2
commit
e08f9b6870
12
LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml
Normal file
12
LawCompany/LawCompanyGuarantorApp/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Home Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h1 class="card-title">LawCompany</h1>
|
||||||
|
<h4>Курсовая работа</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -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]
|
[HttpPost]
|
||||||
public void CreateCase(CaseBindingModel model)
|
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]
|
[HttpPost]
|
||||||
public void DeleteCase(CaseBindingModel model)
|
public void DeleteCase(CaseBindingModel model)
|
||||||
{
|
{
|
||||||
@ -129,21 +98,6 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public void AddClientToCase(Tuple<CaseSearchModel, int> 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]
|
[HttpGet]
|
||||||
public List<ClientViewModel>? GetClientListToCase(int caseId)
|
public List<ClientViewModel>? GetClientListToCase(int caseId)
|
||||||
{
|
{
|
||||||
|
@ -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]
|
[HttpPost]
|
||||||
public void CreateClient(ClientBindingModel model)
|
public void CreateClient(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -23,14 +23,13 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ExecutorViewModel? Login(string fio, string email, string password)
|
public ExecutorViewModel? Login(string login, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _logic.ReadElement(new ExecutorSearchModel
|
return _logic.ReadElement(new ExecutorSearchModel
|
||||||
{
|
{
|
||||||
FIO = fio,
|
Email = login,
|
||||||
Email = email,
|
|
||||||
Password = password,
|
Password = password,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,12 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public GuarantorViewModel? Login(string fio, string login, string password)
|
public GuarantorViewModel? Login(string login, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _logic.ReadElement(new GuarantorSearchModel
|
return _logic.ReadElement(new GuarantorSearchModel
|
||||||
{
|
{
|
||||||
FIO = fio,
|
|
||||||
Email = login,
|
Email = login,
|
||||||
Password = password
|
Password = password
|
||||||
});
|
});
|
||||||
|
135
LawCompany/LawCompanyRestApi/Controllers/ReportController.cs
Normal file
135
LawCompany/LawCompanyRestApi/Controllers/ReportController.cs
Normal file
@ -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<ReportController> 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;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,6 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<VisitViewModel>? GetVisitList(int executorId)
|
public List<VisitViewModel>? GetVisitList(int executorId)
|
||||||
{
|
{
|
||||||
@ -43,7 +40,7 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet("{id}")]
|
||||||
public VisitViewModel? GetVisit(int id)
|
public VisitViewModel? GetVisit(int id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -60,7 +57,6 @@ namespace LawCompanyRestApi.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateVisit(VisitBindingModel model)
|
public void CreateVisit(VisitBindingModel model)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logic.Create(model);
|
_logic.Create(model);
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
|
using HotelBusinessLogic.BusinessLogics;
|
||||||
using LawCompanyBusinessLogic.BusinessLogics;
|
using LawCompanyBusinessLogic.BusinessLogics;
|
||||||
|
using LawCompanyBusinessLogic.OfficePackage.Implements;
|
||||||
|
using LawCompanyBusinessLogic.OfficePackage;
|
||||||
using LawCompanyContracts.BusinessLogicContracts;
|
using LawCompanyContracts.BusinessLogicContracts;
|
||||||
using LawCompanyContracts.StoragesContracts;
|
using LawCompanyContracts.StoragesContracts;
|
||||||
using LawCompanyDatabaseImplement.Implements;
|
using LawCompanyDatabaseImplement.Implements;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using LawCompanyBusinessLogic.MailWorker;
|
||||||
|
using LawCompanyContracts.BindingModels;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -34,6 +39,14 @@ builder.Services.AddTransient<ILawyerLogic, LawyerLogic>();
|
|||||||
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
|
builder.Services.AddTransient<IExecutorLogic, ExecutorLogic>();
|
||||||
builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
|
builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<IReportExecutorLogic, ReportLogicExecutor>();
|
||||||
|
builder.Services.AddTransient<IReportGuarantorLogic, ReportLogicGuarantor>();
|
||||||
|
|
||||||
|
builder.Services.AddTransient<AbstractSaveToWordExecutor, SaveToWordExecutor>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToExcelExecutor, SaveToExcelExecutor>();
|
||||||
|
builder.Services.AddTransient<AbstractSaveToPdfExecutor, SaveToPdfExecutor>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// 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 app = builder.Build();
|
||||||
|
|
||||||
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
||||||
|
|
||||||
|
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.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
"SmtpClientPort": "587",
|
"SmtpClientPort": "587",
|
||||||
"PopHost": "pop.gmail.com",
|
"PopHost": "pop.gmail.com",
|
||||||
"PopPort": "995",
|
"PopPort": "995",
|
||||||
"MailLogin": "lab7yakobchuk@gmail.com",
|
"MailLogin": "laba46466@gmail.com",
|
||||||
"MailPassword": "scht ahjt fxmx tdpc"
|
"MailPassword": "iyin rgai wjdh ocmi"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user