diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/MachineLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/MachineLogic.cs index e7266b8..ec49fea 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/MachineLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/MachineLogic.cs @@ -6,7 +6,7 @@ using FactoryContracts.StoragesContracts; using FactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace FactoryBuisinessLogic.BusinessLogics +namespace FactoryBusinessLogic.BusinessLogics { public class MachineLogic : IMachineLogic { @@ -33,7 +33,19 @@ namespace FactoryBuisinessLogic.BusinessLogics return list; } - public MachineViewModel? ReadElement(MachineSearchModel model) + public List? ReadListByIds(List ids) + { + _logger.LogInformation("ReadListByIds."); + var list = _machineStorage.GetListByIds(ids); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadListByIds. Count:{Count}", list.Count); + return list; + } + public MachineViewModel? ReadElement(MachineSearchModel model) { if (model == null) { diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/ProductLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/ProductLogic.cs index 92c3690..51a5a4c 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/ProductLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/ProductLogic.cs @@ -6,7 +6,7 @@ using FactoryContracts.StoragesContracts; using FactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace FactoryBuisinessLogic.BusinessLogics +namespace FactoryBusinessLogic.BusinessLogics { public class ProductLogic : IProductLogic { diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/RequirementLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/RequirementLogic.cs index 156156e..84fbd79 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/RequirementLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/RequirementLogic.cs @@ -6,7 +6,7 @@ using FactoryContracts.StoragesContracts; using FactoryContracts.ViewModels; using Microsoft.Extensions.Logging; -namespace FactoryBuisinessLogic.BusinessLogics +namespace FactoryBusinessLogic.BusinessLogics { public class RequirementLogic : IRequirementLogic { diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs index 90386a3..2097505 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs @@ -4,7 +4,7 @@ using FactoryContracts.SearchModels; using FactoryContracts.StoragesContracts; using FactoryContracts.ViewModels; -namespace FactoryBuisinessLogic.BusinessLogics +namespace FactoryBusinessLogic.BusinessLogics { public class StorekeeperReportLogic : IStorekeeperReportLogic { diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/WorkerReportLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/WorkerReportLogic.cs index 79ee7ae..68c6f41 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/WorkerReportLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/WorkerReportLogic.cs @@ -4,7 +4,7 @@ using FactoryContracts.SearchModels; using FactoryContracts.StoragesContracts; using FactoryContracts.ViewModels; -namespace FactoryBuisinessLogic.BusinessLogics +namespace FactoryBusinessLogic.BusinessLogics { public class WorkerReportLogic : IWorkerReportLogic { diff --git a/Factory/FactoryContracts/BindingModels/ExecutionPhaseBindingModel.cs b/Factory/FactoryContracts/BindingModels/ExecutionPhaseBindingModel.cs index fe6320b..4c7aa45 100644 --- a/Factory/FactoryContracts/BindingModels/ExecutionPhaseBindingModel.cs +++ b/Factory/FactoryContracts/BindingModels/ExecutionPhaseBindingModel.cs @@ -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; } } diff --git a/Factory/FactoryContracts/BusinessLogicsContracts/IMachineLogic.cs b/Factory/FactoryContracts/BusinessLogicsContracts/IMachineLogic.cs index d054f5f..4ba84ff 100644 --- a/Factory/FactoryContracts/BusinessLogicsContracts/IMachineLogic.cs +++ b/Factory/FactoryContracts/BusinessLogicsContracts/IMachineLogic.cs @@ -8,7 +8,9 @@ namespace FactoryContracts.BusinessLogicsContracts { List? ReadList(MachineSearchModel? model); - MachineViewModel? ReadElement(MachineSearchModel model); + List? ReadListByIds(List ids); + + MachineViewModel? ReadElement(MachineSearchModel model); bool Create(MachineBindingModel model); diff --git a/Factory/FactoryContracts/StoragesContracts/IMachineStorage.cs b/Factory/FactoryContracts/StoragesContracts/IMachineStorage.cs index 48ed476..73aa0ad 100644 --- a/Factory/FactoryContracts/StoragesContracts/IMachineStorage.cs +++ b/Factory/FactoryContracts/StoragesContracts/IMachineStorage.cs @@ -10,7 +10,9 @@ namespace FactoryContracts.StoragesContracts List GetFilteredList(MachineSearchModel model); - List GetMachinesByPeriod(ClientSearchModel client, ReportBindingModel model); + List GetListByIds(List ids); + + List GetMachinesByPeriod(ClientSearchModel client, ReportBindingModel model); MachineViewModel? GetElement(MachineSearchModel model); diff --git a/Factory/FactoryContracts/ViewModels/ExecutionPhaseViewModel.cs b/Factory/FactoryContracts/ViewModels/ExecutionPhaseViewModel.cs index ea28db3..8156318 100644 --- a/Factory/FactoryContracts/ViewModels/ExecutionPhaseViewModel.cs +++ b/Factory/FactoryContracts/ViewModels/ExecutionPhaseViewModel.cs @@ -9,7 +9,7 @@ namespace FactoryContracts.ViewModels public int Id { get; set; } public int ClientId { get; set; } - public int? PlanProductionId { get; set; } + public int PlanProductionId { get; set; } [DisplayName("ФИО исполнителя")] public string ImplementerFIO { get; set; } = string.Empty; diff --git a/Factory/FactoryDataModels/Models/IExecutionPhaseModel.cs b/Factory/FactoryDataModels/Models/IExecutionPhaseModel.cs index 63c4dec..7c40160 100644 --- a/Factory/FactoryDataModels/Models/IExecutionPhaseModel.cs +++ b/Factory/FactoryDataModels/Models/IExecutionPhaseModel.cs @@ -9,6 +9,6 @@ namespace FactoryDataModels.Models string ImplementerFIO { get; } ExecutionPhaseStatus Status { get; } int ClientId { get; } - int? PlanProductionId { get; } + int PlanProductionId { get; } } } diff --git a/Factory/FactoryDataModels/Models/IWorkpieceModel.cs b/Factory/FactoryDataModels/Models/IWorkpieceModel.cs index 7006d24..39cd19b 100644 --- a/Factory/FactoryDataModels/Models/IWorkpieceModel.cs +++ b/Factory/FactoryDataModels/Models/IWorkpieceModel.cs @@ -9,7 +9,8 @@ double Cost { get; } int ClientId { get; } + DateTime DateCreate { get; } - Dictionary WorkpieceProducts { get; } + Dictionary WorkpieceProducts { get; } } } \ No newline at end of file diff --git a/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj b/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj index 46ea071..055429e 100644 --- a/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj +++ b/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj @@ -23,8 +23,4 @@ - - - - diff --git a/Factory/FactoryDatabaseImplement/Implements/MachineStorage.cs b/Factory/FactoryDatabaseImplement/Implements/MachineStorage.cs index a7c0815..2cfb15b 100644 --- a/Factory/FactoryDatabaseImplement/Implements/MachineStorage.cs +++ b/Factory/FactoryDatabaseImplement/Implements/MachineStorage.cs @@ -42,7 +42,19 @@ namespace FactoryDatabaseImplement.Implements .ToList(); } - public MachineViewModel? GetElement(MachineSearchModel model) + public List GetListByIds(List ids) + { + using var context = new FactoryDatabase(); + return context.Machines + .Include(x => x.Client) + .Include (x => x.PlanProductions) + .ThenInclude (x => x.PlanProduction) + .Where(x => ids.Any(y => x.Id == y)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public MachineViewModel? GetElement(MachineSearchModel model) { if (string.IsNullOrEmpty(model.MachineName) && !model.Id.HasValue) { diff --git a/Factory/FactoryDatabaseImplement/Migrations/20240528111521_InitCreate.Designer.cs b/Factory/FactoryDatabaseImplement/Migrations/20240528130831_InitCreate.Designer.cs similarity index 99% rename from Factory/FactoryDatabaseImplement/Migrations/20240528111521_InitCreate.Designer.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240528130831_InitCreate.Designer.cs index a2ec8a6..03514f6 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/20240528111521_InitCreate.Designer.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/20240528130831_InitCreate.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FactoryDatabaseImplement.Migrations { [DbContext(typeof(FactoryDatabase))] - [Migration("20240528111521_InitCreate")] + [Migration("20240528130831_InitCreate")] partial class InitCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -71,8 +71,7 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PlanProductionId") - .IsRequired() + b.Property("PlanProductionId") .HasColumnType("integer"); b.Property("Status") diff --git a/Factory/FactoryDatabaseImplement/Migrations/20240528111521_InitCreate.cs b/Factory/FactoryDatabaseImplement/Migrations/20240528130831_InitCreate.cs similarity index 100% rename from Factory/FactoryDatabaseImplement/Migrations/20240528111521_InitCreate.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240528130831_InitCreate.cs diff --git a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs index 49c1f75..6e38073 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs @@ -69,8 +69,7 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PlanProductionId") - .IsRequired() + b.Property("PlanProductionId") .HasColumnType("integer"); b.Property("Status") diff --git a/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs b/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs index 1badcfc..c65f032 100644 --- a/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs +++ b/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs @@ -12,11 +12,11 @@ namespace FactoryDatabaseImplement.Models public int Id { get; private set; } [Required] public int ClientId { get; private set; } - public virtual Client Client { get; private set; } = new(); + public virtual Client Client { get; private set; } [Required] - public int? PlanProductionId { get; private set; } - public virtual PlanProduction PlanProduction { get; private set; } = new(); + public int PlanProductionId { get; private set; } + public virtual PlanProduction PlanProduction { get; private set; } [Required] public string ExecutionPhaseName { get; private set; } = string.Empty; diff --git a/Factory/FactoryDatabaseImplement/Models/Machine.cs b/Factory/FactoryDatabaseImplement/Models/Machine.cs index 6d47dbd..64cb574 100644 --- a/Factory/FactoryDatabaseImplement/Models/Machine.cs +++ b/Factory/FactoryDatabaseImplement/Models/Machine.cs @@ -13,7 +13,7 @@ namespace FactoryDatabaseImplement.Models [Required] public int ClientId { get; private set; } - public virtual Client Client { get; private set; } = new(); + public virtual Client Client { get; private set; } [Required] public string MachineName { get; private set; } = string.Empty; diff --git a/Factory/FactoryDatabaseImplement/Models/MachinePlanProduction.cs b/Factory/FactoryDatabaseImplement/Models/MachinePlanProduction.cs index 68fde24..caf1762 100644 --- a/Factory/FactoryDatabaseImplement/Models/MachinePlanProduction.cs +++ b/Factory/FactoryDatabaseImplement/Models/MachinePlanProduction.cs @@ -15,8 +15,8 @@ namespace FactoryDatabaseImplement.Models [Required] public int Count { get; set; } - public virtual PlanProduction PlanProduction { get; set; } = new(); + public virtual PlanProduction PlanProduction { get; set; } - public virtual Machine Machine { get; set; } = new(); + public virtual Machine Machine { get; set; } } } \ No newline at end of file diff --git a/Factory/FactoryDatabaseImplement/Models/Product.cs b/Factory/FactoryDatabaseImplement/Models/Product.cs index d1fb68f..c9ba330 100644 --- a/Factory/FactoryDatabaseImplement/Models/Product.cs +++ b/Factory/FactoryDatabaseImplement/Models/Product.cs @@ -13,12 +13,12 @@ namespace FactoryDatabaseImplement.Models [Required] public int ClientId { get; private set; } - public virtual Client Client { get; private set; } = new(); + public virtual Client Client { get; private set; } [Required] public int RequirementId { get; private set; } - public virtual Requirement Requirement { get; private set; } = new(); + public virtual Requirement Requirement { get; private set; } [Required] public string ProductName { get; private set; } = string.Empty; diff --git a/Factory/FactoryDatabaseImplement/Models/Requirement.cs b/Factory/FactoryDatabaseImplement/Models/Requirement.cs index 3e03c7e..c00b183 100644 --- a/Factory/FactoryDatabaseImplement/Models/Requirement.cs +++ b/Factory/FactoryDatabaseImplement/Models/Requirement.cs @@ -13,7 +13,7 @@ namespace FactoryDatabaseImplement.Models [Required] public int ClientId { get; private set; } - public virtual Client Client { get; private set; } = new(); + public virtual Client Client { get; private set; } [Required] public string RequirementName { get; private set; } = string.Empty; @@ -25,7 +25,7 @@ namespace FactoryDatabaseImplement.Models public int Lifetime { get; private set; } [ForeignKey("RequirementId")] - public virtual Product Product { get; private set; } = new(); + public virtual Product Product { get; private set; } public static Requirement Create(RequirementBindingModel model) { diff --git a/Factory/FactoryDatabaseImplement/Models/Workpiece.cs b/Factory/FactoryDatabaseImplement/Models/Workpiece.cs index 1045ba6..23e67d0 100644 --- a/Factory/FactoryDatabaseImplement/Models/Workpiece.cs +++ b/Factory/FactoryDatabaseImplement/Models/Workpiece.cs @@ -14,7 +14,7 @@ namespace FactoryDatabaseImplement.Models public string WorkpieceName { get; set; } = string.Empty; [Required] public int ClientId { get; set; } - public virtual Client Client { get; set; } = new Client(); + public virtual Client Client { get; set; } [Required] public string Material { get; set; } = string.Empty; diff --git a/Factory/FactoryRestApi/Controllers/StorekeeperController.cs b/Factory/FactoryRestApi/Controllers/StorekeeperController.cs new file mode 100644 index 0000000..9e0e031 --- /dev/null +++ b/Factory/FactoryRestApi/Controllers/StorekeeperController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; + +namespace FactoryRestApi.Controllers +{ + public class StorekeeperController : Controller + { + public IActionResult Index() + { + return View(); + } + } +} diff --git a/Factory/FactoryRestApi/FactoryRestApi.csproj b/Factory/FactoryRestApi/FactoryRestApi.csproj new file mode 100644 index 0000000..2c33b1c --- /dev/null +++ b/Factory/FactoryRestApi/FactoryRestApi.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Factory/FactoryRestApi/Program.cs b/Factory/FactoryRestApi/Program.cs new file mode 100644 index 0000000..48863a6 --- /dev/null +++ b/Factory/FactoryRestApi/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Factory/FactoryRestApi/Properties/launchSettings.json b/Factory/FactoryRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..9c966c9 --- /dev/null +++ b/Factory/FactoryRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:65510", + "sslPort": 44345 + } + }, + "profiles": { + "FactoryRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7230;http://localhost:5003", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Factory/FactoryRestApi/appsettings.Development.json b/Factory/FactoryRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Factory/FactoryRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Factory/FactoryRestApi/appsettings.json b/Factory/FactoryRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Factory/FactoryRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Factory/FactoryStorekeeperApp/Client.cs b/Factory/FactoryStorekeeperApp/Client.cs new file mode 100644 index 0000000..94b72fc --- /dev/null +++ b/Factory/FactoryStorekeeperApp/Client.cs @@ -0,0 +1,9 @@ +using FactoryContracts.ViewModels; + +namespace FactoryStorekeeperApp +{ + public static class Client + { + public static ClientViewModel? client { get; set; } + } +} diff --git a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs index 826c720..c38c331 100644 --- a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs +++ b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs @@ -2,6 +2,7 @@ using FactoryContracts.BusinessLogicsContracts; using FactoryContracts.SearchModels; using FactoryContracts.ViewModels; +using FactoryDataModels.Enums; using FactoryDataModels.Models; using FactoryStorekepeerApp.Models; using Microsoft.AspNetCore.Mvc; @@ -12,13 +13,18 @@ namespace FactoryStorekeeperApp.Controllers public class HomeController : Controller { private readonly ILogger _logger; + private readonly IClientLogic clientLogic; private readonly IMachineLogic machineLogic; private readonly IRequirementLogic requirementLogic; private readonly IProductLogic productLogic; - public HomeController(ILogger logger, IRequirementLogic requirementLogic, IProductLogic productLogic, IMachineLogic machineLogic) + private bool IsLoggedIn { get { return Client.client != null; } } + private int UserId { get { return Client.client!.Id; } } + + public HomeController(ILogger logger, IClientLogic clientLogic, IRequirementLogic requirementLogic, IProductLogic productLogic, IMachineLogic machineLogic) { _logger = logger; + this.clientLogic = clientLogic; this.requirementLogic = requirementLogic; this.productLogic = productLogic; this.machineLogic = machineLogic; @@ -26,6 +32,10 @@ namespace FactoryStorekeeperApp.Controllers public IActionResult Index() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(); } @@ -38,32 +48,78 @@ namespace FactoryStorekeeperApp.Controllers [HttpGet] public IActionResult Enter() { + if (IsLoggedIn) + { + return Redirect("~/Home/Index"); + } + return View(); + } + + [HttpPost] + public IActionResult Enter(string login, string password) + { + var existsClient = clientLogic.ReadElement(new ClientSearchModel { Login = login, Password = password }); + + if (existsClient != null) + { + Client.client = existsClient; + } return View(); } [HttpGet] public IActionResult Register() { + if (IsLoggedIn) + { + return Redirect("~/Home/Index"); + } return View(); } + [HttpPost] + public IActionResult Register(string login, string email, string password, string passwordConfirm) + { + if (!password.Equals(passwordConfirm)) + { + return Error(); + } + clientLogic.Create(new ClientBindingModel + { + Email = email, + Login = login, + Password = password, + Role = ClientRole.Кладовщик + }); + return Redirect("~/Home/Index"); + } + [HttpGet] public IActionResult Machines() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(machineLogic.ReadList(null)); } [HttpGet] public IActionResult Machine() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(); } [HttpPost] - public void Machine(string machinename, DateTime exploitationstartdate, int lifetime) + public IActionResult Machine(string machinename, DateTime exploitationstartdate, int lifetime) { var element = machineLogic.ReadElement(new MachineSearchModel { MachineName = machinename, + ClientId = Client.client.Id, }); if (element == null) { machineLogic.Create(new MachineBindingModel @@ -71,6 +127,7 @@ namespace FactoryStorekeeperApp.Controllers MachineName = machinename, ExploitationStartDate = exploitationstartdate, Lifetime = lifetime, + ClientId = Client.client.Id, }); } else @@ -80,36 +137,48 @@ namespace FactoryStorekeeperApp.Controllers MachineName = machinename, ExploitationStartDate = exploitationstartdate, Lifetime = lifetime, - }); + ClientId = Client.client.Id, + }); } - Redirect("~/Home/Machines"); + return Redirect("~/Home/Machines"); } [HttpGet] public IActionResult Products() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(productLogic.ReadList(null)); } [HttpGet] public IActionResult Product() { + if (!IsLoggedIn) + { + return Enter(); + } return View(machineLogic.ReadList(null)); } [HttpPost] - public void Product(string productname, int price, List machinetable) + public void Product(string productname, int price, List machines) { var element = productLogic.ReadElement(new ProductSearchModel { ProductName = productname, - }); + ClientId = Client.client.Id, + }); + var machineList = machineLogic.ReadListByIds(machines); if (element == null) { productLogic.Create(new ProductBindingModel { ProductName = productname, Price = price, - ProductMachines = machinetable.ToDictionary(recPC => recPC.Id, recPC => recPC as IMachineModel), - }); + ProductMachines = machineList.ToDictionary(recPC => recPC.Id, recPC => recPC as IMachineModel), + ClientId = Client.client.Id, + }); } else { @@ -117,32 +186,49 @@ namespace FactoryStorekeeperApp.Controllers { ProductName = productname, Price = price, - ProductMachines = machinetable.ToDictionary(recPC => recPC.Id, recPC => recPC as IMachineModel), - }); + ProductMachines = machineList.ToDictionary(recPC => recPC.Id, recPC => recPC as IMachineModel), + ClientId = Client.client.Id, + }); } Redirect("~/Home/Products"); } [HttpGet] public IActionResult Requirements() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(requirementLogic.ReadList(null)); } [HttpGet] public IActionResult Requirement() { + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } return View(); } [HttpGet] public IActionResult Reports() { - return View(); + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } + return View(); } [HttpGet] public IActionResult MachinePeriodReport() { - List reports = new List + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } + List reports = new List { new MachinePeriodReportViewModel { @@ -163,7 +249,11 @@ namespace FactoryStorekeeperApp.Controllers [HttpGet] public IActionResult PlanProductionByProductReport() { - List productPlanProductions = new List + if (!IsLoggedIn) + { + return Redirect("~/Home/Enter"); + } + List productPlanProductions = new List { new ProductPlanProductionReportViewModel { diff --git a/Factory/FactoryStorekeeperApp/Program.cs b/Factory/FactoryStorekeeperApp/Program.cs index ea99b48..4e7b728 100644 --- a/Factory/FactoryStorekeeperApp/Program.cs +++ b/Factory/FactoryStorekeeperApp/Program.cs @@ -1,4 +1,4 @@ -using FactoryBuisinessLogic.BusinessLogics; +using FactoryBusinessLogic.BusinessLogics; using FactoryContracts.BusinessLogicsContracts; using FactoryContracts.StoragesContracts; using FactoryDatabaseImplement.Implements; @@ -6,17 +6,17 @@ using FactoryDatabaseImplement.Implements; var builder = WebApplication.CreateBuilder(args); // Add services to the container. +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); -//builder.Services.AddSingleton(); - builder.Services.AddControllersWithViews(); var app = builder.Build(); diff --git a/Factory/FactoryStorekeeperApp/Views/Home/Product.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/Product.cshtml index 89cd719..7aa2121 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/Product.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/Product.cshtml @@ -14,27 +14,9 @@
Цена:
-
+
Станки:
- - - - - - - - - @foreach (var machine in Model) - { - - - - - } - -
Название
- - @machine.MachineName
+
diff --git a/Factory/FactoryWorkerApp/Program.cs b/Factory/FactoryWorkerApp/Program.cs index 33a5902..9b88c69 100644 --- a/Factory/FactoryWorkerApp/Program.cs +++ b/Factory/FactoryWorkerApp/Program.cs @@ -1,6 +1,5 @@ using FactoryContracts.BusinessLogicsContracts; using FactoryBusinessLogic.BusinessLogics; -using FactoryBuisinessLogic.BusinessLogics; using FactoryContracts.StoragesContracts; using FactoryDatabaseImplement.Implements; using FactoryWorkerApp;