частичная реализация crud.
This commit is contained in:
parent
fdb2ac315c
commit
e467c50904
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace FactoryContracts.BindingModels
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
|
||||
public int ClientId { get; set; }
|
||||
public int PlanProductionId { get; set; }
|
||||
public int? PlanProductionId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace FactoryContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public DateTime DateCreate { get; set; }
|
||||
public string WorkpieceName { get; set; } = string.Empty;
|
||||
public string Material { get; set; } = string.Empty;
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace FactoryContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStorekeeperReportLogic
|
||||
{
|
||||
List<ProductPlanProductionReportViewModel> GetProductPlanProduction(List<ProductSearchModel> products);
|
||||
List<PlanProductionProductReportViewModel> GetPlanProductionProduct(List<PlanProductionSearchModel> plans);
|
||||
List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
|
||||
void SavePlanProductionsToWordFile(ReportBindingModel model);
|
||||
void SavePlanProductionsToExcelFile(ReportBindingModel model);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
public class ExecutionPhaseSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public string? ExecutionPhaseName { get; set; }
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace FactoryContracts.SearchModels
|
||||
public class PlanProductionSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public string? ProductionName { get; set; }
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int? PlanProductionId { get; set; }
|
||||
|
||||
public int? ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? RequirementName { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,10 @@
|
||||
public class WorkpieceSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? WorkpieceName { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace FactoryContracts.ViewModels
|
||||
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Описание этапа")]
|
||||
[DisplayName("Название этапа")]
|
||||
public string ExecutionPhaseName { get; set; } = string.Empty;
|
||||
[DisplayName("Название плана")]
|
||||
public string PlanProductionName { get; set; } = string.Empty;
|
||||
|
@ -18,5 +18,8 @@ namespace FactoryContracts.ViewModels
|
||||
public double Cost { get; set; }
|
||||
[DisplayName("Изделия")]
|
||||
public Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; set; } = new();
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ namespace FactoryDataModels.Models
|
||||
string ImplementerFIO { get; }
|
||||
ExecutionPhaseStatus Status { get; }
|
||||
int ClientId { get; }
|
||||
int PlanProductionId { get; }
|
||||
int? PlanProductionId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ namespace FactoryDatabaseImplement.Implements
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
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))
|
||||
{
|
||||
return context.Products
|
||||
|
@ -28,6 +28,8 @@ namespace FactoryDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
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
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Products)
|
||||
|
@ -21,6 +21,9 @@ namespace FactoryDatabaseImplement.Models
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
private Dictionary<int, (IProductModel, int)>? _workpieceProducts = null;
|
||||
|
||||
[NotMapped]
|
||||
@ -51,6 +54,7 @@ namespace FactoryDatabaseImplement.Models
|
||||
Cost = model.Cost,
|
||||
Material = model.Material,
|
||||
ClientId = model.ClientId,
|
||||
DateCreate = model.DateCreate,
|
||||
Products = model.WorkpieceProducts.Select(x => new WorkpieceProduct
|
||||
{
|
||||
Product = context.Products.First(y => y.Id == x.Key),
|
||||
@ -73,6 +77,7 @@ namespace FactoryDatabaseImplement.Models
|
||||
Cost = Cost,
|
||||
Material = Material,
|
||||
ClientId = ClientId,
|
||||
DateCreate = DateCreate,
|
||||
WorkpieceProducts = WorkpieceProducts
|
||||
};
|
||||
|
||||
|
9
Factory/FactoryWorkerApp/Client.cs
Normal file
9
Factory/FactoryWorkerApp/Client.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using FactoryContracts.ViewModels;
|
||||
|
||||
namespace FactoryWorkerApp
|
||||
{
|
||||
public static class Client
|
||||
{
|
||||
public static ClientViewModel? user { get; set; }
|
||||
}
|
||||
}
|
@ -1,27 +1,31 @@
|
||||
using FactoryContracts.BindingModels;
|
||||
using FactoryContracts.ViewModels;
|
||||
using FactoryDatabaseImplement.Models;
|
||||
using FactoryDataModels.Enums;
|
||||
using FactoryWorkerApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FactoryWorkerApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
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;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
//if (APIClient.Client == null)
|
||||
//{
|
||||
// return Redirect("~/Home/Enter");
|
||||
//}
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("Enter");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -34,128 +38,160 @@ namespace FactoryWorkerApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
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]
|
||||
public IActionResult Register()
|
||||
{
|
||||
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]
|
||||
public IActionResult Workpieces()
|
||||
{
|
||||
List<WorkpieceViewModel> workpieces = new List<WorkpieceViewModel>
|
||||
if (Client.user != null)
|
||||
{
|
||||
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()
|
||||
var list = _logic.GetWorkpieces(Client.user.Id); ;
|
||||
if (list != null)
|
||||
return View(list);
|
||||
return View(new List<WorkpieceViewModel>());
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void Workpieces(int id)
|
||||
{
|
||||
if (Client.user != null)
|
||||
{
|
||||
_logic.DeleteWorkpiece(id);
|
||||
}
|
||||
Response.Redirect("Workpieces");
|
||||
}
|
||||
};
|
||||
|
||||
return View(workpieces);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Workpiece()
|
||||
public IActionResult Workpiece(int id)
|
||||
{
|
||||
var products = new List<ProductViewModel>();
|
||||
products.Add(new ProductViewModel
|
||||
var products = _logic.GetProducts();
|
||||
ViewBag.AllProducts = products;
|
||||
if (id != 0)
|
||||
{
|
||||
Id = 1,
|
||||
ClientId = 1,
|
||||
Price = 99.99,
|
||||
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);
|
||||
|
||||
var value = _logic.GetWorkpiece(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
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]
|
||||
public IActionResult PlanProductions()
|
||||
{
|
||||
List<PlanProductionViewModel> planProductions = new List<PlanProductionViewModel>
|
||||
if (IsLoggedIn)
|
||||
{
|
||||
new PlanProductionViewModel
|
||||
{
|
||||
Id = 1,
|
||||
Count= 1,
|
||||
ProductionName = "План 1",
|
||||
Deadline= DateTime.Now,
|
||||
ClientId= 1,
|
||||
PlanProductionWorkpieces = new()
|
||||
},
|
||||
new PlanProductionViewModel
|
||||
{
|
||||
Id = 2,
|
||||
Count = 2,
|
||||
ProductionName = "План 2",
|
||||
Deadline= DateTime.Now,
|
||||
ClientId= 2,
|
||||
PlanProductionWorkpieces = new()
|
||||
var list = _logic.GetPlanProductions(Client.user!.Id);
|
||||
return View(list);
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult PlanProductions(int id)
|
||||
{
|
||||
_logic.DeletePlanProduction(id);
|
||||
return RedirectToAction("PlanProductions");
|
||||
}
|
||||
};
|
||||
|
||||
return View(planProductions);
|
||||
}
|
||||
[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();
|
||||
}
|
||||
[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]
|
||||
public IActionResult Reports()
|
||||
{
|
||||
@ -203,56 +239,49 @@ namespace FactoryWorkerApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult ExecutionPhases()
|
||||
{
|
||||
List<ExecutionPhaseViewModel> executionPhases = new List<ExecutionPhaseViewModel>
|
||||
if (Client.user != null)
|
||||
{
|
||||
new ExecutionPhaseViewModel
|
||||
{
|
||||
Id = 1,
|
||||
ExecutionPhaseName = "Этап 1",
|
||||
ClientId= 1,
|
||||
PlanProductionId = 1,
|
||||
PlanProductionName = "План 1",
|
||||
ImplementerFIO = "Исполнитель 1",
|
||||
Status= ExecutionPhaseStatus.Выдан
|
||||
},
|
||||
new ExecutionPhaseViewModel
|
||||
{
|
||||
Id = 1,
|
||||
ExecutionPhaseName = "Этап 2",
|
||||
ClientId= 2,
|
||||
PlanProductionId = 2,
|
||||
PlanProductionName = "План 2",
|
||||
ImplementerFIO = "Исполнитель 2",
|
||||
Status= ExecutionPhaseStatus.Готов
|
||||
var list = _logic.GetExecutionPhases(Client.user.Id);
|
||||
return View(list);
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult ExecutionPhases(int id)
|
||||
{
|
||||
_logic.DeleteExecutionPhase(id);
|
||||
return RedirectToAction("ExecutionPhases");
|
||||
}
|
||||
};
|
||||
|
||||
return View(executionPhases);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ExecutionPhase()
|
||||
public IActionResult ExecutionPhase(int id)
|
||||
{
|
||||
var planProductions = new List<PlanProductionViewModel>();
|
||||
planProductions.Add(new PlanProductionViewModel
|
||||
var plans = _logic.GetPlanProductions(Client.user!.Id);
|
||||
ViewBag.AllPlans = plans;
|
||||
if (id != 0)
|
||||
{
|
||||
Id = 1,
|
||||
ClientId = 1,
|
||||
Count = 1,
|
||||
Deadline = DateTime.Now,
|
||||
ProductionName = "План 1",
|
||||
PlanProductionWorkpieces = new()
|
||||
});
|
||||
planProductions.Add(new PlanProductionViewModel
|
||||
var value = _logic.GetExecutionPhase(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new ExecutionPhaseViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
// доделать
|
||||
public IActionResult ExecutionPhase(int id, string title, int planId)
|
||||
{
|
||||
Id = 2,
|
||||
ClientId = 2,
|
||||
Count = 2,
|
||||
Deadline = DateTime.Now,
|
||||
ProductionName = "План 2",
|
||||
PlanProductionWorkpieces = new()
|
||||
});
|
||||
return View(planProductions);
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
@using FactoryDataModels.Enums
|
||||
@using FactoryContracts.ViewModels
|
||||
|
||||
@model ExecutionPhaseViewModel;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Workpiece";
|
||||
@ -9,13 +12,17 @@
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">План производства:</div>
|
||||
<div class="col-8">
|
||||
<select id="planproduction" name="planproduction" class="form-control"></select>
|
||||
</div>
|
||||
<select id="PlanProductionSelect" class="form-control">
|
||||
<option value="">Выберите план</option>
|
||||
@foreach (var planProduction in ViewBag.AllPlans)
|
||||
{
|
||||
<option value="@planProduction.Id">@planProduction.PlanProductionName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<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 class="row">
|
||||
<div class="col-4">Статус:</div>
|
||||
|
@ -1,4 +1,7 @@
|
||||
@{
|
||||
@using FactoryContracts.ViewModels
|
||||
|
||||
@model PlanProductionViewModel;
|
||||
@{
|
||||
ViewData["Title"] = "Plan Production";
|
||||
}
|
||||
<div class="text-center">
|
||||
@ -7,15 +10,15 @@
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<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 class="row">
|
||||
<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 class="row">
|
||||
<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 class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -1,8 +1,9 @@
|
||||
@using FactoryContracts.ViewModels
|
||||
|
||||
@model List<ProductViewModel>
|
||||
@model WorkpieceViewModel;
|
||||
@{
|
||||
ViewData["Title"] = "Workpiece";
|
||||
ViewBag.Products = Model.WorkpieceProducts;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Заготовка</h2>
|
||||
@ -20,7 +21,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var product in Model)
|
||||
@foreach (var product in ViewBag.AllProducts)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@ -38,15 +39,15 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<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 class="row">
|
||||
<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 class="row">
|
||||
<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 class="row">
|
||||
<div class="col-8"></div>
|
||||
|
111
Factory/FactoryWorkerApp/WorkerLogic.cs
Normal file
111
Factory/FactoryWorkerApp/WorkerLogic.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"WorkpieceedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"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
Loading…
Reference in New Issue
Block a user