aaaaaa
This commit is contained in:
parent
9c0e9e0f44
commit
1a4521db91
@ -186,7 +186,12 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook(); CreateStyles(workbookpart);
|
||||
|
@ -186,7 +186,12 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||
workbookpart.Workbook = new Workbook(); CreateStyles(workbookpart);
|
||||
|
@ -39,6 +39,11 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
|
@ -39,6 +39,11 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
{
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
|
@ -74,7 +74,12 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreateWord(WordInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
@ -74,7 +74,12 @@ namespace BeatySalonBusinesLogic.OfficePackage.Implements
|
||||
}
|
||||
protected override void CreateWord(WordInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
string directoryPath = @"C:\reports\";
|
||||
if (!Directory.Exists(directoryPath))
|
||||
{
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
}
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
@ -11,5 +11,6 @@ namespace BeautySalonContracts.BindingModels
|
||||
public string MailAddress { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
}
|
||||
public string Path { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace BeautySalonDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=ALYONA\;Initial Catalog=BeautySalonDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=PRETTYNAME;Initial Catalog=BeautySalonDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace BeautySalonRestApi.Controllers
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public WorkerViewModel? Login(string login, string password)
|
||||
{
|
||||
|
@ -18,11 +18,12 @@ namespace WorkerWebApp
|
||||
_worker.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static async Task<T?> GetRequest<T>(string requestUrl)
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = await _worker.GetAsync(requestUrl);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
if (response.IsSuccessStatusCode)
|
||||
var response = _worker.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
@ -32,18 +33,19 @@ namespace WorkerWebApp
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task PostRequest<T>(string requestUrl, T model)
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await _worker.PostAsync(requestUrl, data);
|
||||
var response = _worker.PostAsync(requestUrl, data);
|
||||
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,26 +4,44 @@ using WorkerWebApp.Models;
|
||||
using WorkerWebApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonBusinesLogic.MailWorker;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
|
||||
namespace WorkerWebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkerLogic _logic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly IProcedureLogic _procedureLogic;
|
||||
|
||||
private readonly IReportLogicWorker _reportLogic;
|
||||
|
||||
private readonly AbstractMailWorker _mailLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IWorkerLogic workerLogic, IProcedureLogic procedureLogic, IReportLogicWorker reportLogic, AbstractMailWorker mailLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = workerLogic;
|
||||
_procedureLogic = procedureLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_mailLogic = mailLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
//if (APIWorker.Worker == null)
|
||||
//{
|
||||
// return Redirect("~/Home/Enter");
|
||||
//}
|
||||
//return View(APIWorker.GetRequest<List<OrderViewModel>>($"api/main/getorders?workerId={APIWorker.Worker.Id}"));
|
||||
return View();
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APIWorker.Worker);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -48,7 +66,7 @@ namespace WorkerWebApp.Controllers
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIWorker.PostRequest("api/worker/updatedata", new WorkerBindingModel
|
||||
_logic.Update(new WorkerBindingModel
|
||||
{
|
||||
Id = APIWorker.Worker.Id,
|
||||
FullName = fio,
|
||||
@ -58,9 +76,240 @@ namespace WorkerWebApp.Controllers
|
||||
APIWorker.Worker.FullName = fio;
|
||||
APIWorker.Worker.Email = login;
|
||||
APIWorker.Worker.Password = password;
|
||||
|
||||
Response.Redirect("Privacy");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
if (APIWorker.Worker != null)
|
||||
{
|
||||
throw new Exception("Вы уже авторизовались!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
APIWorker.Worker = _logic.ReadElement(new WorkerSearchModel
|
||||
{
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
if (APIWorker.Worker != null)
|
||||
{
|
||||
throw new Exception("Вы уже зарегистрировались!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string fullname, string email, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_logic.Create(new WorkerBindingModel
|
||||
{
|
||||
FullName = fullname,
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
[HttpGet]
|
||||
public void Logout()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
APIWorker.Worker = null;
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Reports()
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(new ProcedureSearchModel
|
||||
{
|
||||
WorkerId = APIWorker.Worker.Id
|
||||
});
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Reports(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
var data = _reportLogic.GetOrders(new ReportOrderBindingModel
|
||||
{
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
ViewBag.Procedures = _procedureLogic.ReadList(new ProcedureSearchModel
|
||||
{
|
||||
WorkerId = APIWorker.Worker.Id
|
||||
});
|
||||
|
||||
return View(data);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportWord(List<int> procedures, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
if (procedures == null || procedures.Count <= 0)
|
||||
{
|
||||
throw new Exception("Не выбраны рецепты!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveProcedureCosmeticsToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список процедур {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.docx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportExcel(List<int> procedures, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
if (procedures == null || procedures.Count <= 0)
|
||||
{
|
||||
throw new Exception("Не выбраны рецепты!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveProcedureCosmeticsToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список процедур {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportPdf(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveOrdersToPdfFile(new ReportOrderBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список заказов{DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
WorkerId = APIWorker.Worker.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendReport(IFormFile fileUpload)
|
||||
{
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (fileUpload == null || fileUpload.Length <= 0)
|
||||
{
|
||||
throw new Exception("Файл не выбран или пуст!");
|
||||
}
|
||||
|
||||
// Путь до файла
|
||||
var uploadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\";
|
||||
var fileName = Path.GetFileName(fileUpload.FileName);
|
||||
var fullPath = Path.Combine(uploadPath, fileName);
|
||||
|
||||
_mailLogic.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = APIWorker.Worker.Email,
|
||||
Subject = $"{fileName.Split('.')[0]}",
|
||||
Text = $"Отчёт отправлен {DateTime.Now}",
|
||||
Path = fullPath
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||
NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
@ -76,20 +325,17 @@ namespace WorkerWebApp.Controllers
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task Enter(string login, string password)
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
|
||||
APIWorker.Worker = await APIWorker.GetRequest<WorkerViewModel>($"api/worker/login?login={login}&password={password}");
|
||||
|
||||
APIWorker.Worker = APIWorker.GetRequest<WorkerViewModel>($"api/workercontroller/login?login={login}&password={password}");
|
||||
if (APIWorker.Worker == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -140,5 +386,5 @@ namespace WorkerWebApp.Controllers
|
||||
{
|
||||
return View(new List<OrderViewModel>()); //тут тоже вопрос
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
@ -1,10 +1,73 @@
|
||||
using BeautySalonBusinesLogic.BusinessLogic;
|
||||
using BeautySalonBusinesLogic.MailWorker;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeatySalonBusinesLogic.OfficePackage.Implements;
|
||||
using BeatySalonBusinesLogic.OfficePackage;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using CafeBusinessLogic.BusinessLogics;
|
||||
using BeautySalonBusinesLogic.BusinessLogics;
|
||||
using BeautySalonDatabaseImplement.Implements;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
// Logger service
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IEvaluationStorage, EvaluationStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<ILaborCostsStorage, LaborCostsStorage>();
|
||||
builder.Services.AddTransient<ICosmeticStorage, CosmeticStorage>();
|
||||
builder.Services.AddTransient<IStorekeeperStorage, StorekeeperStorage>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IEvaluationLogic, EvaluationLogic>();
|
||||
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
|
||||
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<ILaborCostsLogic, LaborCostsLogic>();
|
||||
builder.Services.AddTransient<ICosmeticLogic, CosmeticLogic>();
|
||||
builder.Services.AddTransient<IStorekeeperLogic, StorekeeperLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToWordStorekeeper, SaveToWordStorekeeper>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordWorker, SaveToWordWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelWorker, SaveToExcelWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelStorekeeper, SaveToExcelStorekeeper>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfWorker, SaveToPdfWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfStorekeeper, SaveToPdfStorekeeper>();
|
||||
|
||||
builder.Services.AddTransient<IReportLogicStorekeeper, ReportStorekeeperLogic>();
|
||||
builder.Services.AddTransient<IReportLogicWorker, ReportWorkerLogic>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configuration for MailService
|
||||
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.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -11,7 +11,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonBusinesLogic\BeautySalonBusinesLogic.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -9,7 +9,7 @@ namespace StorekeeperWebApp
|
||||
{
|
||||
private static readonly HttpClient _storekeeper = new();
|
||||
|
||||
public static StorekeeperViewModel? Storekeeper { get; set; } = null;
|
||||
public static StorekeeperViewModel? Worker { get; set; } = null;
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
|
@ -0,0 +1,124 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
public class CosmeticController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
|
||||
public CosmeticController(ILogger<CosmeticController> logger, ICosmeticLogic cosmetic)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CosmeticViewModel? GetCosmetic(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CosmeticViewModel>? Cosmetics()
|
||||
{
|
||||
try
|
||||
{
|
||||
var cosmetics = cosmetic.ReadList(null); // Получение списка косметики
|
||||
|
||||
List<CosmeticViewModel> cosmeticViewModels = new List<CosmeticViewModel>();
|
||||
|
||||
// Преобразование данных косметики в список CosmeticViewModel
|
||||
foreach (var item in cosmetics)
|
||||
{
|
||||
CosmeticViewModel cosmeticViewModel = new CosmeticViewModel
|
||||
{
|
||||
// Присваивание значений свойствам модели CosmeticViewModel
|
||||
// Например: cosmeticViewModel.Property = item.Property;
|
||||
};
|
||||
|
||||
cosmeticViewModels.Add(cosmeticViewModel);
|
||||
}
|
||||
|
||||
return cosmeticViewModels;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения списка косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CosmeticViewModel>? GetCosmetics(int laborcostId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cosmetic.ReadList(new CosmeticSearchModel { LaborCostId = laborcostId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения списка косметики с id трудозатраты = {Id}", laborcostId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCosmetic(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка создания косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCosmetic(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка обновления косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteCosmetic(CosmeticBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
cosmetic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка удаления косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +1,64 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using StorekeeperWebApp;
|
||||
using WorkerWebApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StorekeeperWebApp.Models;
|
||||
using System.Diagnostics;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonBusinesLogic.MailWorker;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using StorekeeperWebApp.Models;
|
||||
using StorekeeperWebApp;
|
||||
|
||||
namespace StorekeeperWebApp.Controllers
|
||||
namespace WorkerWebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStorekeeperLogic _logic;
|
||||
|
||||
private readonly ICosmeticLogic _cosmeticLogic;
|
||||
|
||||
private readonly IReportLogicStorekeeper _reportLogic;
|
||||
|
||||
private readonly AbstractMailWorker _mailLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IStorekeeperLogic workerLogic, ICosmeticLogic cosmeticLogic, IReportLogicStorekeeper reportLogic, AbstractMailWorker mailLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = workerLogic;
|
||||
_cosmeticLogic = cosmeticLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_mailLogic = mailLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
if (APIStorekeeper.Storekeeper == null)
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIStorekeeper.GetRequest<List<OrderViewModel>>($"api/main/getorders?storekeeperId={APIStorekeeper.Storekeeper.Id}"));
|
||||
|
||||
return View(APIStorekeeper.Worker);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (APIStorekeeper.Storekeeper == null)
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIStorekeeper.Storekeeper);
|
||||
return View(APIStorekeeper.Worker);
|
||||
}
|
||||
[HttpPost]
|
||||
|
||||
public void Privacy(string login, string password, string fio)
|
||||
{
|
||||
if (APIStorekeeper.Storekeeper == null)
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
@ -45,136 +67,237 @@ namespace StorekeeperWebApp.Controllers
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIStorekeeper.PostRequest("api/storekeeper/updatedata", new StorekeeperBindingModel
|
||||
_logic.Update(new StorekeeperBindingModel
|
||||
{
|
||||
Id = APIStorekeeper.Storekeeper.Id,
|
||||
Id = APIStorekeeper.Worker.Id,
|
||||
FullName = fio,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
APIStorekeeper.Storekeeper.FullName = fio;
|
||||
APIStorekeeper.Storekeeper.Email = login;
|
||||
APIStorekeeper.Storekeeper.Password = password;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None,
|
||||
NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel
|
||||
{
|
||||
RequestId =
|
||||
Activity.Current?.Id ?? HttpContext.TraceIdentifier
|
||||
});
|
||||
APIStorekeeper.Worker.FullName = fio;
|
||||
APIStorekeeper.Worker.Email = login;
|
||||
APIStorekeeper.Worker.Password = password;
|
||||
|
||||
Response.Redirect("Privacy");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
if (APIStorekeeper.Worker != null)
|
||||
{
|
||||
throw new Exception("Вы уже авторизовались!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
APIStorekeeper.Storekeeper =
|
||||
APIStorekeeper.GetRequest<StorekeeperViewModel>($"api/storekeeper/login?login={login}&password={password}");
|
||||
if (APIStorekeeper.Storekeeper == null)
|
||||
|
||||
APIStorekeeper.Worker = _logic.ReadElement(new StorekeeperSearchModel
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string login, string password, string fio)
|
||||
{
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIStorekeeper.PostRequest("api/storekeeper/register", new
|
||||
StorekeeperBindingModel
|
||||
{
|
||||
FullName = fio,
|
||||
Email = login,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//повар
|
||||
[HttpGet]
|
||||
public IActionResult Services()
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View(new List<ServiceViewModel>());
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ServiceCreate()
|
||||
{
|
||||
return View(new List<ServiceViewModel>());
|
||||
if (APIStorekeeper.Worker != null)
|
||||
{
|
||||
throw new Exception("Вы уже зарегистрировались!");
|
||||
}
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ServiceCreate(string serviceName, int servicePrice, int experience)
|
||||
public void Register(string fullname, string email, string password)
|
||||
{
|
||||
/*if (APIStorekeeper.Storekeeper == null)
|
||||
if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Вход только авторизованным");
|
||||
}*/
|
||||
APIStorekeeper.PostRequest("api/chef/chefcreate", new ServiceBindingModel
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_logic.Create(new StorekeeperBindingModel
|
||||
{
|
||||
StorekeeperId = APIStorekeeper.Storekeeper.Id,
|
||||
ServiceName = serviceName,
|
||||
ServicePrice = servicePrice,
|
||||
|
||||
FullName = fullname,
|
||||
Email = email,
|
||||
Password = password
|
||||
});
|
||||
Response.Redirect("Chefs");
|
||||
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult LaborCostUpdate()
|
||||
public void Logout()
|
||||
{
|
||||
return View(new List<LaborCostsViewModel>());//тут тоже вопрос
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
APIStorekeeper.Worker = null;
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Reports()
|
||||
{
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Cosmetics()
|
||||
{
|
||||
return View(new List<CosmeticViewModel>());//уверенности ноль
|
||||
ViewBag.Cosmetics = _cosmeticLogic.ReadList(new CosmeticSearchModel());
|
||||
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CosmeticCreate()
|
||||
[HttpPost]
|
||||
public IActionResult Reports(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return View(new List<CosmeticViewModel>());
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
var data = _reportLogic.GetServices(new ReportServiceBindingModel
|
||||
{
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
ViewBag.Cosmetic = _cosmeticLogic.ReadList(new CosmeticSearchModel());
|
||||
|
||||
return View(data);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CosmeticUpdate()
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportWord(List<int> procedures, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return View(new List<CosmeticViewModel>());
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
if (procedures == null || procedures.Count <= 0)
|
||||
{
|
||||
throw new Exception("Не выбраны рецепты!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список процедур {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.docx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult LaborCosts()
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportExcel(List<int> procedures, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return View(new List<LaborCostsViewModel>());
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
if (procedures == null || procedures.Count <= 0)
|
||||
{
|
||||
throw new Exception("Не выбраны рецепты!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список процедур {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportPdf(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return View(new List<ServiceViewModel>());//вопрос
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (dateFrom == DateTime.MinValue || dateTo == DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
|
||||
{
|
||||
FileName = $@"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\Downloads\Список услуг{DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx",
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo,
|
||||
StorekeeperId = APIStorekeeper.Worker.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult List()
|
||||
|
||||
[HttpPost]
|
||||
public void SendReport(IFormFile fileUpload)
|
||||
{
|
||||
return View(new List<CosmeticViewModel>());//вопрос
|
||||
if (APIStorekeeper.Worker == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (fileUpload == null || fileUpload.Length <= 0)
|
||||
{
|
||||
throw new Exception("Файл не выбран или пуст!");
|
||||
}
|
||||
|
||||
// Путь до файла
|
||||
var uploadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\";
|
||||
var fileName = Path.GetFileName(fileUpload.FileName);
|
||||
var fullPath = Path.Combine(uploadPath, fileName);
|
||||
|
||||
_mailLogic.MailSendAsync(new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = APIStorekeeper.Worker.Email,
|
||||
Subject = $"{fileName.Split('.')[0]}",
|
||||
Text = $"Отчёт отправлен {DateTime.Now}",
|
||||
Path = fullPath
|
||||
});
|
||||
|
||||
Response.Redirect("/Home/Reports");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
public class LaborCostsController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ILaborCostsLogic _logic;
|
||||
|
||||
public LaborCostsController(ILaborCostsLogic logic, ILogger<LaborCostsController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public LaborCostsViewModel? GetLaborCosts(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new LaborCostsSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<LaborCostsViewModel>? GetAllLaborCosts()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка трудозатрат");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateLaborCosts(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateLaborCosts(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteLaborCosts(LaborCostsBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления трудозатраты");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BeautySalonRestApi.Controllers
|
||||
{
|
||||
public class ServiceController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IServiceLogic _logic;
|
||||
|
||||
public ServiceController(IServiceLogic logic, ILogger<ServiceController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public ServiceViewModel? GetService(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ServiceSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetAllServices()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка услуг");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel>? GetServices(int storekeeperId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(new ServiceSearchModel { StorekeeperId = storekeeperId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка услуг сотрудника id={Id}", storekeeperId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void CreateService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public void DeleteService(ServiceBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,73 @@
|
||||
using BeautySalonBusinesLogic.BusinessLogic;
|
||||
using BeautySalonBusinesLogic.MailWorker;
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.BusinessLogicContracts;
|
||||
using BeautySalonContracts.BusinessLogicsContracts;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeatySalonBusinesLogic.OfficePackage.Implements;
|
||||
using BeatySalonBusinesLogic.OfficePackage;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using CafeBusinessLogic.BusinessLogics;
|
||||
using BeautySalonBusinesLogic.BusinessLogics;
|
||||
using BeautySalonDatabaseImplement.Implements;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
// Logger service
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IEvaluationStorage, EvaluationStorage>();
|
||||
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
||||
builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||
|
||||
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
|
||||
builder.Services.AddTransient<ILaborCostsStorage, LaborCostsStorage>();
|
||||
builder.Services.AddTransient<ICosmeticStorage, CosmeticStorage>();
|
||||
builder.Services.AddTransient<IStorekeeperStorage, StorekeeperStorage>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IEvaluationLogic, EvaluationLogic>();
|
||||
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
||||
builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
|
||||
|
||||
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
|
||||
builder.Services.AddTransient<ILaborCostsLogic, LaborCostsLogic>();
|
||||
builder.Services.AddTransient<ICosmeticLogic, CosmeticLogic>();
|
||||
builder.Services.AddTransient<IStorekeeperLogic, StorekeeperLogic>();
|
||||
|
||||
builder.Services.AddTransient<AbstractSaveToWordStorekeeper, SaveToWordStorekeeper>();
|
||||
builder.Services.AddTransient<AbstractSaveToWordWorker, SaveToWordWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelWorker, SaveToExcelWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToExcelStorekeeper, SaveToExcelStorekeeper>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfWorker, SaveToPdfWorker>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdfStorekeeper, SaveToPdfStorekeeper>();
|
||||
|
||||
builder.Services.AddTransient<IReportLogicStorekeeper, ReportStorekeeperLogic>();
|
||||
builder.Services.AddTransient<IReportLogicWorker, ReportWorkerLogic>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configuration for MailService
|
||||
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.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
|
@ -11,11 +11,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonBusinesLogic\BeautySalonBusinesLogic.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonContracts\BeautySalonContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<ProjectReference Include="..\BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -0,0 +1,70 @@
|
||||
@using BeautySalonContracts.ViewModels
|
||||
|
||||
@model List<CosmeticViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Косметика";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Косметика</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateDisease">Создать косметику</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Бренд</th>
|
||||
<th>Цена</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var cosmetics in Model)
|
||||
{
|
||||
<tr>
|
||||
<th>@cosmetics.Id</th>
|
||||
<td>@cosmetics.CosmeticName</td>
|
||||
<td>@cosmetics.Brand</td>
|
||||
<td>@cosmetics.CosmeticPrice</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateCosmetic", "/Cosmetic", new { id = cosmetics.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteDisease(@cosmetics.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteDisease(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить болезнь?")) {
|
||||
$.post('@Url.Action("DeleteDisease", "/Disease")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
|
@ -32,19 +32,16 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Авторизация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Service">Услуги</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Service" asp-action="GetAllServices">Услуги</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="LaborCosts">Трудозатраты</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Cosmetic" asp-action="Cosmetics">Косметика</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Cosmetic">Косметика</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="LaborCost" asp-action="GetAllLaborCosts">Трудозатраты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ListCosmetics">Список</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчет</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Reports">Отчет</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user