заказы починены

This commit is contained in:
Milana Ievlewa 2024-08-28 18:55:12 +04:00
parent d3bb4ef56c
commit 858ab6b996
4 changed files with 241 additions and 170 deletions

View File

@ -162,7 +162,7 @@ namespace StorekeeperApp
report.CosmeticName = cosmetic!.CosmeticName;
var procedures = _procedureLogic.ReadList(null);
List<ProcedureViewModel> filteredProcedures = new List<ProcedureViewModel>();
HashSet<ProcedureViewModel> filteredProcedures = new HashSet<ProcedureViewModel>();
if (cosmetic.CosmeticServices != null && procedures != null)
{

View File

@ -413,7 +413,7 @@ namespace CarCenterWorkerApp.Controllers
return RedirectToAction("ProcedureCosmeticChoose");
}
[HttpGet]
public IActionResult ProcedureCosmeticReport()
public IActionResult ProcedureCosmeticsReport()
{
var value = HttpContext.Session.GetString("Procedures");
if (value != null)

View File

@ -3,86 +3,63 @@
@model List<OrderViewModel>
@{
ViewData["Title"] = "Orders";
ViewData["Title"] = "Orders";
}
<div class="text-center">
<h1 class="display-4">Заказы</h1>
<h1 class="display-4">Заказы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateOrder" asp-route-id="0">Создать заказ</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Тип оплаты
</th>
<th>
Статус оплаты
</th>
<th>
Дата оплаты
</th>
<th>
Имя работника
</th>
<th>
Сумма
</th>
<th>
Изменить заказ
</th>
<th>
Удалить заказ
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.PaymentType)
</td>
<td>
@Html.DisplayFor(modelItem => item.PaymentStatus)
</td>
<td>
@Html.DisplayFor(modelItem => item.PaymentDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.WorkerName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sum)
</td>
<td>
<a asp-action="CreateOrder" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>
</table>
}
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateOrder" asp-route-id="0">Создать заказ</a>
</p>
<table class="table">
<thead>
<tr>
<th>Номер</th>
<th>Тип оплаты</th>
<th>Статус оплаты</th>
<th>Дата оплаты</th>
<th>Имя работника</th>
<th>Сумма</th>
<th>Изменить заказ</th>
<th>Удалить заказ</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Id)</td>
<td>@Html.DisplayFor(modelItem => item.PaymentType)</td>
<td>@Html.DisplayFor(modelItem => item.PaymentStatus)</td>
<td>
@if (item.PaymentStatus == CarCenterDataModels.Enums.PaymentStatus.Оплачено)
{
@Html.DisplayFor(modelItem => item.PaymentDate)
}
</td>
<td>@Html.DisplayFor(modelItem => item.WorkerName)</td>
<td>@Html.DisplayFor(modelItem => item.Sum)</td>
<td>
<a asp-action="CreateOrder" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -9,25 +9,26 @@ using DocumentFormat.OpenXml.Spreadsheet;
using CarCenterDataModels.Models;
using CarCenterBusinessLogic.MailWorker;
using CarCenterBusinessLogic.OfficePackage;
using CarCenterDatabaseImplement.Models;
namespace WorkerApp
{
public class WorkerData
{
private readonly ILogger _logger;
private readonly IWorkerLogic _storekeeperLogic;
private readonly IProcedureLogic _procedureLogic;
private readonly IRatingLogic _ratingLogic;
private readonly IOrderLogic _orderLogic;
private readonly ICosmeticLogic _cosmeticLogic;
public class WorkerData
{
private readonly ILogger _logger;
private readonly IWorkerLogic _storekeeperLogic;
private readonly IProcedureLogic _procedureLogic;
private readonly IRatingLogic _ratingLogic;
private readonly IOrderLogic _orderLogic;
private readonly ICosmeticLogic _cosmeticLogic;
private readonly IServiceLogic _serviceLogic;
private readonly AbstractSaveToExcelWorker _excel;
private readonly AbstractSaveToWordWorker _word;
private readonly AbstractSaveToPdfWorker _pdf;
private readonly AbstractMailWorker _mail;
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IProcedureLogic procedureLogic,
IRatingLogic ratingLogic, IOrderLogic orderLogic, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic,
public WorkerData(ILogger<WorkerData> logger, IWorkerLogic storekeeperLogic, IProcedureLogic procedureLogic,
IRatingLogic ratingLogic, IOrderLogic orderLogic, IServiceLogic serviceLogic, ICosmeticLogic cosmeticLogic,
AbstractSaveToExcelWorker excel,
AbstractSaveToWordWorker word,
AbstractMailWorker mail,
@ -47,82 +48,82 @@ namespace WorkerApp
}
public WorkerViewModel? Login(string email, string password)
{
return _storekeeperLogic.ReadElement(new()
{
Email = email,
Password = password
});
}
public bool Register(WorkerBindingModel model)
{
return _storekeeperLogic.Create(model);
}
public bool UpdateUser(WorkerBindingModel model)
{
return _storekeeperLogic.Update(model);
}
{
return _storekeeperLogic.ReadElement(new()
{
Email = email,
Password = password
});
}
public bool Register(WorkerBindingModel model)
{
return _storekeeperLogic.Create(model);
}
public bool UpdateUser(WorkerBindingModel model)
{
return _storekeeperLogic.Update(model);
}
public List<ProcedureViewModel>? GetProcedures(int userId)
{
return _procedureLogic.ReadList(new ProcedureSearchModel() { WorkerId = userId });
}
public bool DeleteProcedure(int procedureId)
{
return _procedureLogic.Delete(new() { Id = procedureId });
}
public bool CreateProcedure(ProcedureBindingModel model)
{
return _procedureLogic.Create(model);
}
public bool UpdateProcedure(ProcedureBindingModel model)
{
return _procedureLogic.Update(model);
}
public ProcedureViewModel? GetProcedure(int id)
{
return _procedureLogic.ReadElement(new() { Id = id });
}
public List<RatingViewModel>? GetRatings(int userId)
{
return _ratingLogic.ReadList(new RatingSearchModel() { WorkerId = userId });
}
public bool DeleteRating(int procedureId)
{
return _ratingLogic.Delete(new() { Id = procedureId });
}
public bool CreateRating(RatingBindingModel model)
{
return _ratingLogic.Create(model);
}
public bool UpdateRating(RatingBindingModel model)
{
return _ratingLogic.Update(model);
}
public RatingViewModel? GetRating(int id)
{
return _ratingLogic.ReadElement(new() { Id = id });
}
public List<OrderViewModel>? GetOrders(int userId)
{
return _orderLogic.ReadList(new() { WorkerId = userId });
}
public OrderViewModel? GetOrder(int id)
{
return _orderLogic.ReadElement(new() { Id = id });
}
public bool CreateOrder(OrderBindingModel model)
{
return _orderLogic.Create(model);
}
public bool UpdateOrder(OrderBindingModel model)
{
return _orderLogic.Update(model);
}
public bool DeleteOrder(int orderId)
{
return _orderLogic.Delete(new() { Id = orderId });
}
public List<ProcedureViewModel>? GetProcedures(int userId)
{
return _procedureLogic.ReadList(new ProcedureSearchModel() { WorkerId = userId });
}
public bool DeleteProcedure(int procedureId)
{
return _procedureLogic.Delete(new() { Id = procedureId });
}
public bool CreateProcedure(ProcedureBindingModel model)
{
return _procedureLogic.Create(model);
}
public bool UpdateProcedure(ProcedureBindingModel model)
{
return _procedureLogic.Update(model);
}
public ProcedureViewModel? GetProcedure(int id)
{
return _procedureLogic.ReadElement(new() { Id = id });
}
public List<RatingViewModel>? GetRatings(int userId)
{
return _ratingLogic.ReadList(new RatingSearchModel() { WorkerId = userId });
}
public bool DeleteRating(int procedureId)
{
return _ratingLogic.Delete(new() { Id = procedureId });
}
public bool CreateRating(RatingBindingModel model)
{
return _ratingLogic.Create(model);
}
public bool UpdateRating(RatingBindingModel model)
{
return _ratingLogic.Update(model);
}
public RatingViewModel? GetRating(int id)
{
return _ratingLogic.ReadElement(new() { Id = id });
}
public List<OrderViewModel>? GetOrders(int userId)
{
return _orderLogic.ReadList(new() { WorkerId = userId });
}
public OrderViewModel? GetOrder(int id)
{
return _orderLogic.ReadElement(new() { Id = id });
}
public bool CreateOrder(OrderBindingModel model)
{
return _orderLogic.Create(model);
}
public bool UpdateOrder(OrderBindingModel model)
{
return _orderLogic.Update(model);
}
public bool DeleteOrder(int orderId)
{
return _orderLogic.Delete(new() { Id = orderId });
}
public List<ServiceViewModel>? GetServices()
{
return _serviceLogic.ReadList(null);
@ -143,12 +144,105 @@ namespace WorkerApp
{
var report = new ReportOrderViewModel();
report.OrderId = order.Id;
var ratings = _ratingLogic.ReadList(new() { OrderId = order.Id, WorkerId = UserId });
if (ratings != null)
report.Ratings = ratings.Select(p => p.Id.ToString()).ToList();
var services = _serviceLogic.ReadList(new() { OrderId = order.Id, StorekeeperId = UserId });
if (services != null)
report.Services = services.Select(p => p.Id.ToString()).ToList();
var services = _serviceLogic.ReadList(null);
HashSet<ServiceViewModel> filteredServices = new HashSet<ServiceViewModel>();
List<IRatingModel> rmodels = new List<IRatingModel>();
HashSet<double> ratings = new HashSet<double>();
if (order.OrderProcedures != null && services != null)
{
var proceduresO = new HashSet<IProcedureModel>(order.OrderProcedures.Values);//получаем процедуры,
//фигурирующие в заказе
var procedures = _procedureLogic.ReadList(null);//все процедуры в формате ViewMode
foreach (var procedure in proceduresO)
{
foreach (var pr in procedures)
{
if (procedure.Id == pr.Id)
{
foreach (var point in pr.Ratings)
{
rmodels.Add(point.Value);
}
}
}
}
List<IServiceModel> servs = new List<IServiceModel>();//заполняем услугами из процедур
//(тут еще пока IServiceMOdel и повторы)
foreach (var p in procedures)
{
foreach (var pc in proceduresO)
{
if (p.Id == pc.Id)
{
foreach (var s in p.ProcedureServices)
{
servs.Add(s.Value);
}
}
}
}
foreach(var sv in servs)
{
foreach(var s in services)
{
if(sv.Id == s.Id)
{
filteredServices.Add(s);
}
}
}
}
/*foreach (var service in services)
{
if (service.ServiceProcedures != null)
{
var proceduresS = new HashSet<IProcedureModel>(service.ServiceProcedures.Values);
foreach (IProcedureModel proc in proceduresS)
{
foreach (IProcedureModel p in proceduresO)
{
if (p.Id == proc.Id)
{
filteredServices.Add(service);
break;
}
}
}
}
}
}*/
var rats = _ratingLogic.ReadList(null);
foreach (var rats1 in rats)
{
foreach (var r1 in rmodels)
{
if (rats1.Id == r1.Id)
{
ratings.Add(rats1.Points);
}
}
}
report.Services = filteredServices.Select(w => w.ServiceName).ToList();
foreach (double rat in ratings)
{
report.Ratings.Add(rat.ToString());
}
orderTimeReports.Add(report);
}
return orderTimeReports;
@ -164,7 +258,7 @@ namespace WorkerApp
report.ProcedureName = procedure!.ProcedureName;
var cosmetics = _cosmeticLogic.ReadList(null);
List<CosmeticViewModel> filteredCosmetics = new List<CosmeticViewModel>();
HashSet<CosmeticViewModel> filteredCosmetics = new HashSet<CosmeticViewModel>();
if (procedure.ProcedureServices != null && cosmetics != null)
{