частичная реализация crud.

This commit is contained in:
sardq 2024-05-27 19:35:49 +04:00
parent fdb2ac315c
commit e467c50904
31 changed files with 423 additions and 189 deletions

View File

@ -0,0 +1,39 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
namespace FactoryBuisinessLogic.BusinessLogics
{
public class WorkerReportLogic : IWorkerReportLogic
{
private readonly IMachineStorage _machineStorage;
private readonly IProductStorage _productStorage;
public WorkerReportLogic(IMachineStorage machineStorage, IProductStorage productStorage)
{
_machineStorage = machineStorage;
_productStorage = productStorage;
}
public List<ProductPlanProductionReportViewModel> GetProductPlanProduction(List<ProductSearchModel> products)
{
return _productStorage.GetPlanProductions(products);
}
public List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model)
{
return _machineStorage.GetMachinesByPeriod(client, model);
}
public void SaveMachinesToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SavePlanProductionsToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SavePlanProductionsToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -11,7 +11,7 @@ namespace FactoryContracts.BindingModels
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен; public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
public int ClientId { get; set; } public int ClientId { get; set; }
public int PlanProductionId { get; set; } public int? PlanProductionId { get; set; }
} }

View File

@ -6,7 +6,7 @@ namespace FactoryContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int ClientId { get; set; } public int ClientId { get; set; }
public DateTime DateCreate { get; set; }
public string WorkpieceName { get; set; } = string.Empty; public string WorkpieceName { get; set; } = string.Empty;
public string Material { get; set; } = string.Empty; public string Material { get; set; } = string.Empty;

View File

@ -6,7 +6,7 @@ namespace FactoryContracts.BusinessLogicsContracts
{ {
public interface IStorekeeperReportLogic public interface IStorekeeperReportLogic
{ {
List<ProductPlanProductionReportViewModel> GetProductPlanProduction(List<ProductSearchModel> products); List<PlanProductionProductReportViewModel> GetPlanProductionProduct(List<PlanProductionSearchModel> plans);
List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model); List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
void SavePlanProductionsToWordFile(ReportBindingModel model); void SavePlanProductionsToWordFile(ReportBindingModel model);
void SavePlanProductionsToExcelFile(ReportBindingModel model); void SavePlanProductionsToExcelFile(ReportBindingModel model);

View File

@ -0,0 +1,15 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IWorkerReportLogicc
{
List<ProductPlanProductionReportViewModel> GetProductPlanProduction(List<ProductSearchModel> products);
List<WorkpieceTimeReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
void SavePlanProductionsToWordFile(ReportBindingModel model);
void SavePlanProductionsToExcelFile(ReportBindingModel model);
void SaveMachinesToPdfFile(ReportBindingModel model);
}
}

View File

@ -3,6 +3,7 @@
public class ExecutionPhaseSearchModel public class ExecutionPhaseSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; }
public string? ExecutionPhaseName { get; set; } public string? ExecutionPhaseName { get; set; }
} }

View File

@ -5,6 +5,7 @@ namespace FactoryContracts.SearchModels
public class PlanProductionSearchModel public class PlanProductionSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; }
public string? ProductionName { get; set; } public string? ProductionName { get; set; }
} }
} }

View File

@ -4,6 +4,8 @@
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? ProductName { get; set; } public string? ProductName { get; set; }
public int ClientId { get; set; } public int? PlanProductionId { get; set; }
public int? ClientId { get; set; }
} }
} }

View File

@ -4,6 +4,6 @@
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? RequirementName { get; set; } public string? RequirementName { get; set; }
public int ClientId { get; set; } public int? ClientId { get; set; }
} }
} }

View File

@ -3,7 +3,10 @@
public class WorkpieceSearchModel public class WorkpieceSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? WorkpieceName { get; set; } public string? WorkpieceName { get; set; }
public int? ClientId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
} }
} }

View File

@ -13,7 +13,7 @@ namespace FactoryContracts.ViewModels
[DisplayName("ФИО исполнителя")] [DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty; public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Описание этапа")] [DisplayName("Название этапа")]
public string ExecutionPhaseName { get; set; } = string.Empty; public string ExecutionPhaseName { get; set; } = string.Empty;
[DisplayName("Название плана")] [DisplayName("Название плана")]
public string PlanProductionName { get; set; } = string.Empty; public string PlanProductionName { get; set; } = string.Empty;

View File

@ -18,5 +18,8 @@ namespace FactoryContracts.ViewModels
public double Cost { get; set; } public double Cost { get; set; }
[DisplayName("Изделия")] [DisplayName("Изделия")]
public Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; set; } = new(); public Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; set; } = new();
[DisplayName("Дата создания")]
public DateTime DateCreate { get; set; }
} }
} }

View File

@ -9,6 +9,6 @@ namespace FactoryDataModels.Models
string ImplementerFIO { get; } string ImplementerFIO { get; }
ExecutionPhaseStatus Status { get; } ExecutionPhaseStatus Status { get; }
int ClientId { get; } int ClientId { get; }
int PlanProductionId { get; } int? PlanProductionId { get; }
} }
} }

View File

@ -24,6 +24,9 @@ namespace FactoryDatabaseImplement.Implements
public List<ProductViewModel> GetFilteredList(ProductSearchModel model) public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
{ {
using var context = new FactoryDatabase(); using var context = new FactoryDatabase();
if (model.PlanProductionId.HasValue)
//return context.Products.Where(x => x.ProductionId.HasValue).Include(x => x.Production).Where(x => x.Production.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList();
if (!string.IsNullOrEmpty(model.ProductName)) if (!string.IsNullOrEmpty(model.ProductName))
{ {
return context.Products return context.Products

View File

@ -28,6 +28,8 @@ namespace FactoryDatabaseImplement.Implements
return new(); return new();
} }
using var context = new FactoryDatabase(); using var context = new FactoryDatabase();
if (model.DateFrom.HasValue)
return context.Workpieces.Where(x => x.ClientId == model.ClientId).Where(x => x.DateCreate <= model.DateTo && x.DateCreate >= model.DateFrom).Select(x => x.GetViewModel).ToList();
return context.Workpieces return context.Workpieces
.Include(x => x.Client) .Include(x => x.Client)
.Include(x => x.Products) .Include(x => x.Products)

View File

@ -21,6 +21,9 @@ namespace FactoryDatabaseImplement.Models
[Required] [Required]
public double Cost { get; set; } public double Cost { get; set; }
[Required]
public DateTime DateCreate { get; set; } = DateTime.Now;
private Dictionary<int, (IProductModel, int)>? _workpieceProducts = null; private Dictionary<int, (IProductModel, int)>? _workpieceProducts = null;
[NotMapped] [NotMapped]
@ -51,6 +54,7 @@ namespace FactoryDatabaseImplement.Models
Cost = model.Cost, Cost = model.Cost,
Material = model.Material, Material = model.Material,
ClientId = model.ClientId, ClientId = model.ClientId,
DateCreate = model.DateCreate,
Products = model.WorkpieceProducts.Select(x => new WorkpieceProduct Products = model.WorkpieceProducts.Select(x => new WorkpieceProduct
{ {
Product = context.Products.First(y => y.Id == x.Key), Product = context.Products.First(y => y.Id == x.Key),
@ -73,6 +77,7 @@ namespace FactoryDatabaseImplement.Models
Cost = Cost, Cost = Cost,
Material = Material, Material = Material,
ClientId = ClientId, ClientId = ClientId,
DateCreate = DateCreate,
WorkpieceProducts = WorkpieceProducts WorkpieceProducts = WorkpieceProducts
}; };

View File

@ -0,0 +1,9 @@
using FactoryContracts.ViewModels;
namespace FactoryWorkerApp
{
public static class Client
{
public static ClientViewModel? user { get; set; }
}
}

View File

@ -1,27 +1,31 @@
using FactoryContracts.BindingModels; using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels; using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using FactoryDataModels.Enums; using FactoryDataModels.Enums;
using FactoryWorkerApp.Models; using FactoryWorkerApp.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
using System.Xml.Linq;
namespace FactoryWorkerApp.Controllers namespace FactoryWorkerApp.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private readonly WorkerLogic _logic;
private bool IsLoggedIn { get { return Client.user != null; } }
private int UserId { get { return Client.user!.Id; } }
public HomeController(ILogger<HomeController> logger) public HomeController(ILogger<HomeController> logger, WorkerLogic logic)
{ {
_logger = logger; _logger = logger;
_logic = logic;
} }
public IActionResult Index() public IActionResult Index()
{ {
//if (APIClient.Client == null) if (!IsLoggedIn)
//{ return RedirectToAction("Enter");
// return Redirect("~/Home/Enter");
//}
return View(); return View();
} }
@ -34,128 +38,160 @@ namespace FactoryWorkerApp.Controllers
[HttpGet] [HttpGet]
public IActionResult Enter() public IActionResult Enter()
{ {
if (!IsLoggedIn)
return View(); return View();
return RedirectToAction("Index");
}
[HttpPost]
public void Enter(string login, string password)
{
var user = _logic.Login(login, password);
if (user != null)
{
Client.user = user;
Response.Redirect("Index");
}
} }
[HttpGet] [HttpGet]
public IActionResult Register() public IActionResult Register()
{ {
return View(); return View();
} }
[HttpPost]
public void Register(string name, string login, string email, string password1, string password2)
{
if (password1 == password2 && _logic.Register(new() { Email = email, Login = login, Role = ClientRole.Работник, Password = password1 }))
{
Response.Redirect("Index");
}
}
[HttpGet] [HttpGet]
public IActionResult Workpieces() public IActionResult Workpieces()
{ {
List<WorkpieceViewModel> workpieces = new List<WorkpieceViewModel> if (Client.user != null)
{ {
new WorkpieceViewModel var list = _logic.GetWorkpieces(Client.user.Id); ;
{ if (list != null)
Id = 1, return View(list);
WorkpieceName = "Заготовка 1", return View(new List<WorkpieceViewModel>());
Cost = 10.99, }
ClientId= 1, return RedirectToAction("Index");
Material = "Материал 1", }
WorkpieceProducts= new() [HttpPost]
}, public void Workpieces(int id)
new WorkpieceViewModel {
{ if (Client.user != null)
Id = 2, {
WorkpieceName = "Заготовка 2", _logic.DeleteWorkpiece(id);
Cost = 15.99, }
ClientId= 2, Response.Redirect("Workpieces");
Material = "Материал 2",
WorkpieceProducts= new()
} }
};
return View(workpieces);
}
[HttpGet] [HttpGet]
public IActionResult Workpiece() public IActionResult Workpiece(int id)
{ {
var products = new List<ProductViewModel>(); var products = _logic.GetProducts();
products.Add(new ProductViewModel ViewBag.AllProducts = products;
if (id != 0)
{ {
Id = 1, var value = _logic.GetWorkpiece(id);
ClientId = 1, if (value != null)
Price = 99.99, return View(value);
ProductMachines = new(),
ProductName = "Test",
RequirementId = 1,
RequirementName = "Test"
}) ;
products.Add(new ProductViewModel
{
Id = 1,
ClientId = 2,
Price = 19.99,
ProductMachines = new(),
ProductName = "Test2",
RequirementId = 2,
RequirementName = "Test2"
});
return View(products);
} }
return View(new WorkpieceViewModel());
}
[HttpPost]
public IActionResult Workpiece(WorkpieceBindingModel model)
{
if (model.Id == 0)
{
model.DateCreate = DateTime.Now;
model.ClientId = Client.user!.Id;
if (_logic.CreateWorkpiece(model))
return RedirectToAction("Workpieces");
}
else
{
if (_logic.UpdateWorkpiece(model))
return RedirectToAction("Workpieces");
}
return View();
}
[HttpGet] [HttpGet]
public IActionResult PlanProductions() public IActionResult PlanProductions()
{ {
List<PlanProductionViewModel> planProductions = new List<PlanProductionViewModel> if (IsLoggedIn)
{ {
new PlanProductionViewModel var list = _logic.GetPlanProductions(Client.user!.Id);
{ return View(list);
Id = 1, }
Count= 1, return RedirectToAction("Index");
ProductionName = "План 1", }
Deadline= DateTime.Now, [HttpPost]
ClientId= 1, public IActionResult PlanProductions(int id)
PlanProductionWorkpieces = new() {
}, _logic.DeletePlanProduction(id);
new PlanProductionViewModel return RedirectToAction("PlanProductions");
{
Id = 2,
Count = 2,
ProductionName = "План 2",
Deadline= DateTime.Now,
ClientId= 2,
PlanProductionWorkpieces = new()
} }
};
return View(planProductions);
}
[HttpGet] [HttpGet]
public IActionResult PlanProduction() public IActionResult PlanProduction(int id)
{ {
if (id != 0)
{
var value = _logic.GetPlanProduction(id);
if (value != null)
return View(value);
}
return View(new PlanProductionViewModel());
}
[HttpPost]
public IActionResult PlanProduction(PlanProductionBindingModel model)
{
if (model.Id == 0)
{
model.ClientId = Client.user!.Id;
if (_logic.CreatePlanProduction(model))
return RedirectToAction("PlanProductions");
}
else
{
if (_logic.UpdatePlanProduction(model))
return RedirectToAction("PlanProductions");
}
return View(); return View();
}
[HttpGet]
public IActionResult ConnectionPlanProductionWorkpiece()
{
List<WorkpieceViewModel> workpieces = new List<WorkpieceViewModel>
{
new WorkpieceViewModel
{
Id = 1,
WorkpieceName = "Заготовка 1",
Cost = 10.99,
ClientId= 1,
Material = "Материал 1",
WorkpieceProducts= new()
},
new WorkpieceViewModel
{
Id = 2,
WorkpieceName = "Заготовка 2",
Cost = 15.99,
ClientId= 2,
Material = "Материал 2",
WorkpieceProducts= new()
}
};
return View(workpieces);
} }
[HttpGet]
public IActionResult ConnectionPlanProductionWorkpiece(int id)
{
if (!IsLoggedIn)
return RedirectToAction("Index");
var plan = _logic.GetPlanProduction(id);
ViewBag.PlanProduction = plan;
var workpieces = _logic.GetWorkpieces(id);
return View(workpieces);
}
[HttpPost]
public IActionResult ConnectionPlanProductionWorkpiece(int planProductionId, int workpieceId)
{
if (!IsLoggedIn)
return RedirectToAction("Index");
var plan = _logic.GetPlanProduction(planProductionId);
if (plan == null)
return RedirectToAction("Index");
PlanProductionBindingModel productBinding = new() { Id = planProductionId, Count = plan.Count, Deadline = plan.Deadline, ClientId= plan.ClientId, ProductionName= plan.ProductionName, PlanProductionWorkpieces = plan.PlanProductionWorkpieces};
//productBinding.PlanProductionWorkpieces.Add(_logic.GetWorkpiece(workpieceId));
_logic.UpdatePlanProduction(productBinding);
return RedirectToAction("Index");
}
[HttpGet] [HttpGet]
public IActionResult Reports() public IActionResult Reports()
{ {
@ -203,56 +239,49 @@ namespace FactoryWorkerApp.Controllers
[HttpGet] [HttpGet]
public IActionResult ExecutionPhases() public IActionResult ExecutionPhases()
{ {
List<ExecutionPhaseViewModel> executionPhases = new List<ExecutionPhaseViewModel> if (Client.user != null)
{ {
new ExecutionPhaseViewModel var list = _logic.GetExecutionPhases(Client.user.Id);
{ return View(list);
Id = 1, }
ExecutionPhaseName = "Этап 1", return RedirectToAction("Index");
ClientId= 1, }
PlanProductionId = 1, [HttpPost]
PlanProductionName = "План 1", public IActionResult ExecutionPhases(int id)
ImplementerFIO = "Исполнитель 1", {
Status= ExecutionPhaseStatus.Выдан _logic.DeleteExecutionPhase(id);
}, return RedirectToAction("ExecutionPhases");
new ExecutionPhaseViewModel
{
Id = 1,
ExecutionPhaseName = "Этап 2",
ClientId= 2,
PlanProductionId = 2,
PlanProductionName = "План 2",
ImplementerFIO = "Исполнитель 2",
Status= ExecutionPhaseStatus.Готов
} }
};
return View(executionPhases);
}
[HttpGet] [HttpGet]
public IActionResult ExecutionPhase() public IActionResult ExecutionPhase(int id)
{ {
var planProductions = new List<PlanProductionViewModel>(); var plans = _logic.GetPlanProductions(Client.user!.Id);
planProductions.Add(new PlanProductionViewModel ViewBag.AllPlans = plans;
if (id != 0)
{ {
Id = 1, var value = _logic.GetExecutionPhase(id);
ClientId = 1, if (value != null)
Count = 1, return View(value);
Deadline = DateTime.Now,
ProductionName = "План 1",
PlanProductionWorkpieces = new()
});
planProductions.Add(new PlanProductionViewModel
{
Id = 2,
ClientId = 2,
Count = 2,
Deadline = DateTime.Now,
ProductionName = "План 2",
PlanProductionWorkpieces = new()
});
return View(planProductions);
} }
return View(new ExecutionPhaseViewModel());
}
[HttpPost]
// доделать
public IActionResult ExecutionPhase(int id, string title, int planId)
{
ExecutionPhaseBindingModel model = new ExecutionPhaseBindingModel();
model.Id = id;
model.ExecutionPhaseName = title;
model.ClientId = Client.user!.Id;
model.PlanProductionId = planId;
if (model.PlanProductionId.HasValue)
{
_logic.UpdateExecutionPhase(model);
}
_logic.CreateExecutionPhase(model);
return RedirectToAction("ExecutionPhases");
}
} }
} }

View File

@ -1,4 +1,7 @@
@using FactoryDataModels.Enums @using FactoryDataModels.Enums
@using FactoryContracts.ViewModels
@model ExecutionPhaseViewModel;
@{ @{
ViewData["Title"] = "Workpiece"; ViewData["Title"] = "Workpiece";
@ -9,13 +12,17 @@
<form method="post"> <form method="post">
<div class="row"> <div class="row">
<div class="col-4">План производства:</div> <div class="col-4">План производства:</div>
<div class="col-8"> <select id="PlanProductionSelect" class="form-control">
<select id="planproduction" name="planproduction" class="form-control"></select> <option value="">Выберите план</option>
</div> @foreach (var planProduction in ViewBag.AllPlans)
{
<option value="@planProduction.Id">@planProduction.PlanProductionName</option>
}
</select>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Название:</div> <div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" /></div> <div class="col-8"><input type="text" name="name" id="name" value="@Model.ExecutionPhaseName"/></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Статус:</div> <div class="col-4">Статус:</div>

View File

@ -1,4 +1,7 @@
@{ @using FactoryContracts.ViewModels
@model PlanProductionViewModel;
@{
ViewData["Title"] = "Plan Production"; ViewData["Title"] = "Plan Production";
} }
<div class="text-center"> <div class="text-center">
@ -7,15 +10,15 @@
<form method="post"> <form method="post">
<div class="row"> <div class="row">
<div class="col-4">Название:</div> <div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="productionname" id="productionname" /></div> <div class="col-8"><input type="text" name="productionname" id="productionname" value="@Model.ProductionName" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Количество:</div> <div class="col-4">Количество:</div>
<div class="col-8"><input type="text" id="count" name="count" readonly /></div> <div class="col-8"><input type="text" id="count" name="count" value="@Model.Count" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Срок выполнения:</div> <div class="col-4">Срок выполнения:</div>
<div class="col-8"><input type="text" id="deadline" name="deadline" readonly /></div> <div class="col-8"><input asp-format="{0:yyyy-MM-dd}" id="deadline" name="deadline" value="@Model.Deadline" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>

View File

@ -1,8 +1,9 @@
@using FactoryContracts.ViewModels @using FactoryContracts.ViewModels
@model List<ProductViewModel> @model WorkpieceViewModel;
@{ @{
ViewData["Title"] = "Workpiece"; ViewData["Title"] = "Workpiece";
ViewBag.Products = Model.WorkpieceProducts;
} }
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Заготовка</h2> <h2 class="display-4">Заготовка</h2>
@ -20,7 +21,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var product in Model) @foreach (var product in ViewBag.AllProducts)
{ {
<tr> <tr>
<td> <td>
@ -38,15 +39,15 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Название:</div> <div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="workpiecename" id="workpiecename" /></div> <div class="col-8"><input type="text" name="workpiecename" id="workpiecename" value="@Model.WorkpieceName" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Материал:</div> <div class="col-4">Материал:</div>
<div class="col-8"><input type="text" name="material" id="material" /></div> <div class="col-8"><input type="text" name="material" id="material" value="@Model.Material" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Цена:</div> <div class="col-4">Цена:</div>
<div class="col-8"><input type="text" id="cost" name="cost" readonly /></div> <div class="col-8"><input type="text" id="cost" name="cost" value="@Model.Cost" /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>

View File

@ -0,0 +1,111 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryWorkerApp
{
public class WorkerLogic
{
private readonly ILogger _logger;
private readonly IClientLogic _clientLogic;
private readonly IWorkpieceLogic _workpieceLogic;
private readonly IPlanProductionLogic _planProductionLogic;
private readonly IProductLogic _productLogic;
private readonly IExecutionPhaseLogic _executionPhaseLogic;
public WorkerLogic(ILogger<WorkerLogic> logger, IClientLogic clientLogic, IWorkpieceLogic workpieceLogic, IPlanProductionLogic planProductionLogic, IExecutionPhaseLogic executionPhaseLogic, IProductLogic productLogic)
{
_logger = logger;
_clientLogic = clientLogic;
_workpieceLogic = workpieceLogic;
_planProductionLogic = planProductionLogic;
_executionPhaseLogic = executionPhaseLogic;
_productLogic = productLogic;
}
public ClientViewModel? Login(string login, string password)
{
return _clientLogic.ReadElement(new()
{
Login = login,
Password = password
});
}
public bool Register(ClientBindingModel model)
{
return _clientLogic.Create(model);
}
public bool UpdateUser(ClientBindingModel model)
{
return _clientLogic.Update(model);
}
public List<WorkpieceViewModel>? GetWorkpieces(int clientId)
{
return _workpieceLogic.ReadList(new WorkpieceSearchModel() { ClientId = clientId });
}
public WorkpieceViewModel? GetWorkpiece(int id)
{
return _workpieceLogic.ReadElement(new() { Id = id });
}
public bool CreateWorkpiece(WorkpieceBindingModel model)
{
return _workpieceLogic.Create(model);
}
public bool UpdateWorkpiece(WorkpieceBindingModel model)
{
return _workpieceLogic.Update(model);
}
public bool DeleteWorkpiece(int workpieceId)
{
return _workpieceLogic.Delete(new() { Id = workpieceId });
}
public List<PlanProductionViewModel>? GetPlanProductions(int clientId)
{
return _planProductionLogic.ReadList(new PlanProductionSearchModel() { ClientId = clientId });
}
public PlanProductionViewModel? GetPlanProduction(int id)
{
return _planProductionLogic.ReadElement(new() { Id = id });
}
public bool CreatePlanProduction(PlanProductionBindingModel model)
{
return _planProductionLogic.Create(model);
}
public bool UpdatePlanProduction(PlanProductionBindingModel model)
{
return _planProductionLogic.Update(model);
}
public bool DeletePlanProduction(int planProductionId)
{
return _planProductionLogic.Delete(new() { Id = planProductionId });
}
public List<ExecutionPhaseViewModel>? GetExecutionPhases(int clientId)
{
return _executionPhaseLogic.ReadList(new ExecutionPhaseSearchModel() { ClientId = clientId });
}
public ExecutionPhaseViewModel? GetExecutionPhase(int id)
{
return _executionPhaseLogic.ReadElement(new() { Id = id });
}
public bool CreateExecutionPhase(ExecutionPhaseBindingModel model)
{
return _executionPhaseLogic.Create(model);
}
public bool UpdateExecutionPhase(ExecutionPhaseBindingModel model)
{
return _executionPhaseLogic.Update(model);
}
public bool DeleteExecutionPhase(int executionPhaseId)
{
return _executionPhaseLogic.Delete(new() { Id = executionPhaseId });
}
public List<ProductViewModel>? GetProducts()
{
return _productLogic.ReadList(null);
}
}
}

View File

@ -1,5 +1,5 @@
{ {
"DetailedErrors": true, "WorkpieceedErrors": true,
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long