⠛⠛⣿⣿⣿⣿⣿⡷⢶⣦⣶⣶⣤⣤⣤⣀⠀⠀⠀

⠀.................../>  フ.....................
     |  _  _|
     /`ミ _x 彡
     /      |
    /  ヽ   ノ
 / ̄|   | | |
 | ( ̄ヽ__ヽ_)_)
 \二つ это котик Гоша Скопируй его и перешли чтобы он захватил мир
This commit is contained in:
Sharosh322 2024-04-30 14:37:13 +04:00
parent 6d5deb344e
commit 58181f08b5
155 changed files with 77548 additions and 0 deletions

49
Factory/Factory.sln Normal file
View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryDataModels", "FactoryDataModels\FactoryDataModels.csproj", "{CBE4843B-F023-4C97-925E-BEFE960D0EEA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryContracts", "FactoryContracts\FactoryContracts.csproj", "{87BA79A9-CF35-4CB4-98BD-86C01918C81C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryBuisinessLogic", "FactoryBuisinessLogic\FactoryBuisinessLogic.csproj", "{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryDatabaseImplement", "FactoryDatabaseImplement\FactoryDatabaseImplement.csproj", "{AC09F9B2-8744-4C66-AD47-33A35613BC40}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryWorkerApp", "FactoryWorkerApp\FactoryWorkerApp.csproj", "{7A1EA01A-5AF5-4D93-A8BB-AFDD4481A080}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CBE4843B-F023-4C97-925E-BEFE960D0EEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBE4843B-F023-4C97-925E-BEFE960D0EEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBE4843B-F023-4C97-925E-BEFE960D0EEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBE4843B-F023-4C97-925E-BEFE960D0EEA}.Release|Any CPU.Build.0 = Release|Any CPU
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.Build.0 = Release|Any CPU
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Release|Any CPU.Build.0 = Release|Any CPU
{AC09F9B2-8744-4C66-AD47-33A35613BC40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC09F9B2-8744-4C66-AD47-33A35613BC40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC09F9B2-8744-4C66-AD47-33A35613BC40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC09F9B2-8744-4C66-AD47-33A35613BC40}.Release|Any CPU.Build.0 = Release|Any CPU
{7A1EA01A-5AF5-4D93-A8BB-AFDD4481A080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A1EA01A-5AF5-4D93-A8BB-AFDD4481A080}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A1EA01A-5AF5-4D93-A8BB-AFDD4481A080}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A1EA01A-5AF5-4D93-A8BB-AFDD4481A080}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8AB53DAE-273C-4081-BC52-E0656BEC52E5}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,120 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace FactoryBusinessLogic.BusinessLogics
{
public class ExecutionPhaseLogic : IExecutionPhaseLogic
{
private readonly ILogger _logger;
private readonly IExecutionPhaseStorage _executionPhaseStorage;
public ExecutionPhaseLogic(ILogger<ExecutionPhaseLogic> logger, IExecutionPhaseStorage executionPhaseStorage)
{
_logger = logger;
_executionPhaseStorage = executionPhaseStorage;
}
public List<ExecutionPhaseViewModel>? ReadList(ExecutionPhaseSearchModel? model)
{
_logger.LogInformation("ReadList. ExecutionPhaseName:{ExecutionPhaseName}. Id:{Id}", model?.ExecutionPhaseName, model?.Id);
var list = model == null ? _executionPhaseStorage.GetFullList() : _executionPhaseStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ExecutionPhaseViewModel? ReadElement(ExecutionPhaseSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ExecutionPhaseName:{ExecutionPhaseName}. Id:{Id}", model.ExecutionPhaseName, model.Id);
var element = _executionPhaseStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ExecutionPhaseBindingModel model)
{
CheckModel(model);
if (_executionPhaseStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ExecutionPhaseBindingModel model)
{
CheckModel(model);
if (_executionPhaseStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ExecutionPhaseBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_executionPhaseStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ExecutionPhaseBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ExecutionPhaseName))
{
throw new ArgumentNullException("Нет названия этапа выполнения", nameof(model.ExecutionPhaseName));
}
if (string.IsNullOrEmpty(model.ImplementerFIO))
{
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
}
if (model.Status == ExecutionPhaseStatus.Неизвестен)
{
throw new ArgumentNullException("Состояние этапа не может быть неизвестно", nameof(model.Status));
}
_logger.LogInformation("ExecutionPhase. ExecutionPhaseName:{ExecutionPhaseName}. ImplementerFIO:{ImplementerFIO}. Status:{Status}. Id:{Id}", model.ExecutionPhaseName, model.ImplementerFIO, model.Status, model.Id);
var element = _executionPhaseStorage.GetElement(new ExecutionPhaseSearchModel
{
ExecutionPhaseName = model.ExecutionPhaseName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Этап с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,115 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
using FactoryContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
namespace FactoryBusinessLogic.BusinessLogics
{
public class PlanProductionLogic : IPlanProductionLogic
{
private readonly ILogger _logger;
private readonly IPlanProductionStorage _planProductionStorage;
public PlanProductionLogic(ILogger<PlanProductionLogic> logger, IPlanProductionStorage planProductionStorage)
{
_logger = logger;
_planProductionStorage = planProductionStorage;
}
public List<PlanProductionViewModel>? ReadList(PlanProductionSearchModel? model)
{
_logger.LogInformation("ReadList. ProductionName:{ProductionName}. Id:{Id}", model?.ProductionName, model?.Id);
var list = model == null ? _planProductionStorage.GetFullList() : _planProductionStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public PlanProductionViewModel? ReadElement(PlanProductionSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ProductionName:{ProductionName}. Id:{Id}", model.ProductionName, model.Id);
var element = _planProductionStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(PlanProductionBindingModel model)
{
CheckModel(model);
if (_planProductionStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(PlanProductionBindingModel model)
{
CheckModel(model);
if (_planProductionStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(PlanProductionBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_planProductionStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(PlanProductionBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ProductionName))
{
throw new ArgumentNullException("Нет названия плана производства", nameof(model.ProductionName));
}
if (model.Count <= 0)
{
throw new ArgumentNullException("Количество должно быть больше 0", nameof(model.Count));
}
_logger.LogInformation("PlanProduction. ProductionName:{ProductionName}. Count:{Count}. Id:{Id}", model.ProductionName, model.Count, model.Id);
var element = _planProductionStorage.GetElement(new PlanProductionSearchModel
{
ProductionName = model.ProductionName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("План производства с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,116 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace FactoryBusinessLogic.BusinessLogics
{
public class WorkpieceLogic : IWorkpieceLogic
{
private readonly ILogger _logger;
private readonly IWorkpieceStorage _workpieceStorage;
public WorkpieceLogic(ILogger<ExecutionPhaseLogic> logger, IWorkpieceStorage workpieceStorage)
{
_logger = logger;
_workpieceStorage = workpieceStorage;
}
public bool Create(WorkpieceBindingModel model)
{
CheckModel(model);
if (_workpieceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(WorkpieceBindingModel model)
{
CheckModel(model);
if (_workpieceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(WorkpieceBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_workpieceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public WorkpieceViewModel? ReadElement(WorkpieceSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. WorkpieceName:{WorkpieceName}. Id:{Id}", model.WorkpieceName, model.Id);
var element = _workpieceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<WorkpieceViewModel>? ReadList(WorkpieceSearchModel? model)
{
_logger.LogInformation("ReadList. WorkpieceName:{WorkpieceName}. Id:{Id}", model?.WorkpieceName, model?.Id);
var list = model == null ? _workpieceStorage.GetFullList() : _workpieceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(WorkpieceBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.WorkpieceName))
{
throw new ArgumentNullException("Нет названия заготовки", nameof(model.WorkpieceName));
}
if (string.IsNullOrEmpty(model.Material))
{
throw new ArgumentNullException("Нет материала для заготовки", nameof(model.Material));
}
if (model.Cost <= 0)
{
throw new ArgumentNullException("Цена заготовки должна быть больше 0", nameof(model.Cost));
}
_logger.LogInformation("Component. WorkpieceName:{WorkpieceName}. Material:{Material}. Cost:{Cost}. Id:{Id}", model.WorkpieceName, model.Material, model.Cost, model.Id);
var element = _workpieceStorage.GetElement(new WorkpieceSearchModel
{
WorkpieceName = model.WorkpieceName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Заготовка с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,119 @@
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace FactoryBusinessLogic.BusinessLogics
{
public class WorkerLogic : IWorkerLogic
{
private readonly ILogger _logger;
private readonly IWorkerStorage _workerStorage;
public WorkerLogic(ILogger<ExecutionPhaseLogic> logger, IWorkerStorage workerStorage)
{
_logger = logger;
_workerStorage = workerStorage;
}
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
{
_logger.LogInformation("ReadList. Login:{Login}. Id:{Id}", model?.Login, model?.Id);
var list = model == null ? _workerStorage.GetFullList() : _workerStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public WorkerViewModel? ReadElement(WorkerSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Login:{Login}. Id:{Id}", model.Login, model.Id);
var element = _workerStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(WorkerBindingModel model)
{
CheckModel(model);
if (_workerStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(WorkerBindingModel model)
{
CheckModel(model);
if (_workerStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(WorkerBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_workerStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(WorkerBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Login))
{
throw new ArgumentNullException("Нет логина клиента", nameof(model.Login));
}
if (string.IsNullOrEmpty(model.Email))
{
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
}
if (string.IsNullOrEmpty(model.Password))
{
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Email));
}
_logger.LogInformation("Worker. Login:{Login}. Email:{Email}. Password:{Password}.", model.Login, model.Email, model.Password);
var element = _workerStorage.GetElement(new WorkerSearchModel
{
Login = model.Login
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким логином уже есть");
}
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FactoryContracts\FactoryContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using FactoryDataModels.Models;
using FactoryDataModels.Enums;
namespace FactoryContracts.BindingModels
{
public class ExecutionPhaseBindingModel : IExecutionPhaseModel
{
public int Id { get; set; }
public string ExecutionPhaseName { get; set; } = string.Empty;
public string ImplementerFIO { get; set; } = string.Empty;
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
public int WorkerId { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class MachineBindingModel : IMachineModel
{
public int Id { get; set; }
public string MachineName { get; set; } = string.Empty;
public DateTime ExploitationStartDate { get; set; } = DateTime.Now;
public int Lifetime { get; set; }
public int WorkerId { get; set; }
public Dictionary<int, (IPlanProductionModel, int)> MachinePlanProductions { get; set; } = new();
}
}

View File

@ -0,0 +1,19 @@
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class PlanProductionBindingModel : IPlanProductionModel
{
public int Id { get; set; }
public int ExecutionPhaseId { get; set; }
public int WorkerId { get; set; }
public string ProductionName { get; set; } = string.Empty;
public int Count { get; set; }
public DateTime Deadline { get; set; }
public Dictionary<int, (IWorkpieceModel, int)> PlanProductionWorkpieces { get; set; } = new();
}
}

View File

@ -0,0 +1,19 @@
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class ProductBindingModel : IProductModel
{
public int Id { get; set; }
public string ProductName { get; set; } = string.Empty;
public double Price { get; set; }
public int WorkerId { get; set; }
public int RequirementId { get; set; }
public Dictionary<int, (IMachineModel, int)> ProductMachines { get; set; } = new();
}
}

View File

@ -0,0 +1,17 @@
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class RequirementBindingModel : IRequirementModel
{
public int Id { get; set; }
public string RequirementName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public int Lifetime { get; set; }
public int WorkerId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using FactoryDataModels.Enums;
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class WorkerBindingModel : IWorkerModel
{
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public WorkerRole Role { get; set; } = WorkerRole.Неизвестен;
}
}

View File

@ -0,0 +1,17 @@
using FactoryDataModels.Models;
namespace FactoryContracts.BindingModels
{
public class WorkpieceBindingModel : IWorkpieceModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
public string WorkpieceName { get; set; } = string.Empty;
public string Material { get; set; } = string.Empty;
public double Cost { get; set; }
public Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; set; } = new();
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IExecutionPhaseLogic
{
List<ExecutionPhaseViewModel>? ReadList(ExecutionPhaseSearchModel? model);
ExecutionPhaseViewModel? ReadElement(ExecutionPhaseSearchModel model);
bool Create(ExecutionPhaseBindingModel model);
bool Update(ExecutionPhaseBindingModel model);
bool Delete(ExecutionPhaseBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IMachineLogic
{
List<MachineViewModel>? ReadList(MachineSearchModel? model);
MachineViewModel? ReadElement(MachineSearchModel model);
bool Create(MachineBindingModel model);
bool Update(MachineBindingModel model);
bool Delete(MachineBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IPlanProductionLogic
{
List<PlanProductionViewModel>? ReadList(PlanProductionSearchModel? model);
PlanProductionViewModel? ReadElement(PlanProductionSearchModel model);
bool Create(PlanProductionBindingModel model);
bool Update(PlanProductionBindingModel model);
bool Delete(PlanProductionBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IProductLogic
{
List<ProductViewModel>? ReadList(ProductSearchModel? model);
ProductViewModel? ReadElement(ProductSearchModel model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IRequirementLogic
{
List<RequirementViewModel>? ReadList(RequirementSearchModel? model);
RequirementViewModel? ReadElement(RequirementSearchModel model);
bool Create(RequirementBindingModel model);
bool Update(RequirementBindingModel model);
bool Delete(RequirementBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IWorkerLogic
{
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
WorkerViewModel? ReadElement(WorkerSearchModel model);
bool Create(WorkerBindingModel model);
bool Update(WorkerBindingModel model);
bool Delete(WorkerBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.BusinessLogicsContracts
{
public interface IWorkpieceLogic
{
List<WorkpieceViewModel>? ReadList(WorkpieceSearchModel? model);
WorkpieceViewModel? ReadElement(WorkpieceSearchModel model);
bool Create(WorkpieceBindingModel model);
bool Update(WorkpieceBindingModel model);
bool Delete(WorkpieceBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FactoryDataModels\FactoryDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
namespace FactoryContracts.SearchModels
{
public class ExecutionPhaseSearchModel
{
public int? Id { get; set; }
public string? ExecutionPhaseName { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace FactoryContracts.SearchModels
{
public class MachineSearchModel
{
public int? Id { get; set; }
public string? MachineName { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using FactoryDataModels.Enums;
namespace FactoryContracts.SearchModels
{
public class PlanProductionSearchModel
{
public int? Id { get; set; }
public string? ProductionName { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace FactoryContracts.SearchModels
{
public class ProductSearchModel
{
public int? Id { get; set; }
public string? ProductName { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace FactoryContracts.SearchModels
{
public class RequirementSearchModel
{
public int? Id { get; set; }
public string? RequirementName { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace FactoryContracts.SearchModels
{
public class WorkerSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace FactoryContracts.SearchModels
{
public class WorkpieceSearchModel
{
public int? Id { get; set; }
public string? WorkpieceName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IExecutionPhaseStorage
{
List<ExecutionPhaseViewModel> GetFullList();
List<ExecutionPhaseViewModel> GetFilteredList(ExecutionPhaseSearchModel model);
ExecutionPhaseViewModel? GetElement(ExecutionPhaseSearchModel model);
ExecutionPhaseViewModel? Insert(ExecutionPhaseBindingModel model);
ExecutionPhaseViewModel? Update(ExecutionPhaseBindingModel model);
ExecutionPhaseViewModel? Delete(ExecutionPhaseBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IMachineStorage
{
List<MachineViewModel> GetFullList();
List<MachineViewModel> GetFilteredList(MachineSearchModel model);
MachineViewModel? GetElement(MachineSearchModel model);
MachineViewModel? Insert(MachineBindingModel model);
MachineViewModel? Update(MachineBindingModel model);
MachineViewModel? Delete(MachineBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IPlanProductionStorage
{
List<PlanProductionViewModel> GetFullList();
List<PlanProductionViewModel> GetFilteredList(PlanProductionSearchModel model);
PlanProductionViewModel? GetElement(PlanProductionSearchModel model);
PlanProductionViewModel? Insert(PlanProductionBindingModel model);
PlanProductionViewModel? Update(PlanProductionBindingModel model);
PlanProductionViewModel? Delete(PlanProductionBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IRequirementStorage
{
List<RequirementViewModel> GetFullList();
List<RequirementViewModel> GetFilteredList(RequirementSearchModel model);
RequirementViewModel? GetElement(RequirementSearchModel model);
RequirementViewModel? Insert(RequirementBindingModel model);
RequirementViewModel? Update(RequirementBindingModel model);
RequirementViewModel? Delete(RequirementBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.ViewModels;
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
namespace FactoryContracts.StoragesContracts
{
public interface IWorkerStorage
{
List<WorkerViewModel> GetFullList();
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
WorkerViewModel? GetElement(WorkerSearchModel model);
WorkerViewModel? Insert(WorkerBindingModel model);
WorkerViewModel? Update(WorkerBindingModel model);
WorkerViewModel? Delete(WorkerBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.ViewModels;
namespace FactoryContracts.StoragesContracts
{
public interface IWorkpieceStorage
{
List<WorkpieceViewModel> GetFullList();
List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model);
WorkpieceViewModel? GetElement(WorkpieceSearchModel model);
WorkpieceViewModel? Insert(WorkpieceBindingModel model);
WorkpieceViewModel? Update(WorkpieceBindingModel model);
WorkpieceViewModel? Delete(WorkpieceBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using FactoryDataModels.Enums;
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class ExecutionPhaseViewModel : IExecutionPhaseModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;
[DisplayName("Описание этапа")]
public string ExecutionPhaseName { get; set; } = string.Empty;
[DisplayName("Статус")]
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,27 @@
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class MachineViewModel : IMachineModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
[DisplayName("Название станка")]
public string MachineName { get; set; } = string.Empty;
[DisplayName("Дата начала эксплуатации станка")]
public DateTime ExploitationStartDate { get; set; } = DateTime.Now;
[DisplayName("Срок службы")]
public int Lifetime { get; set; }
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
[DisplayName("Планы производства")]
public Dictionary<int, (IPlanProductionModel, int)> MachinePlanProductions { get; set; } = new();
}
}

View File

@ -0,0 +1,25 @@
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class PlanProductionViewModel : IPlanProductionModel
{
[DisplayName("Номер")]
public int Id { get; set; }
public int ExecutionPhaseId { get; set; }
public int WorkerId { get; set; }
[DisplayName("Описание этапа выполнения")]
public string ExecutionPhaseName { get; set; } = string.Empty;
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
[DisplayName("Наименование")]
public string ProductionName { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
[DisplayName("Срок выполнения")]
public DateTime Deadline { get; set; }
[DisplayName("Заготовки")]
public Dictionary<int, (IWorkpieceModel, int)> PlanProductionWorkpieces { get; set; } = new();
}
}

View File

@ -0,0 +1,29 @@
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class ProductViewModel : IProductModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
public int RequirementId { get; set; }
[DisplayName("Название продукта")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
[DisplayName("Название требования")]
public string RequirementName { get; set; } = string.Empty;
[DisplayName("Цена продукта")]
public double Price { get; set; }
[DisplayName("Станки")]
public Dictionary<int, (IMachineModel, int)> ProductMachines { get; set; } = new();
}
}

View File

@ -0,0 +1,22 @@
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class RequirementViewModel : IRequirementModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
[DisplayName("Название требования")]
public string RequirementName { get; set; } = string.Empty;
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
[DisplayName("Описание требования")]
public string Description { get; set; } = string.Empty;
[DisplayName("Срок службы")]
public int Lifetime { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using FactoryDataModels.Enums;
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class WorkerViewModel : IWorkerModel
{
public int Id { get; set; }
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Электронная почта")]
public string Email { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Роль")]
public WorkerRole Role { get; set; } = WorkerRole.Неизвестен;
}
}

View File

@ -0,0 +1,25 @@
using FactoryDataModels.Models;
using System.ComponentModel;
namespace FactoryContracts.ViewModels
{
public class WorkpieceViewModel : IWorkpieceModel
{
public int Id { get; set; }
public int WorkerId { get; set; }
[DisplayName("Название заготовки")]
public string WorkpieceName { get; set; } = string.Empty;
[DisplayName("Материал")]
public string Material { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Cost { get; set; }
[DisplayName("Логин работника")]
public string WorkerLogin { get; set; } = string.Empty;
[DisplayName("Изделия")]
public Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; set; } = new();
}
}

View File

@ -0,0 +1,15 @@
namespace FactoryDataModels.Enums
{
public enum ExecutionPhaseStatus
{
Неизвестен = -1,
Принят = 0,
Выполняется = 1,
Готов = 2,
Выдан = 3
}
}

View File

@ -0,0 +1,9 @@
namespace FactoryDataModels.Enums
{
public enum WorkerRole
{
Неизвестен = -1,
Работник = 0,
Кладовщик = 1,
}
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.22" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace FactoryDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,13 @@
using FactoryDataModels.Enums;
namespace FactoryDataModels.Models
{
public interface IExecutionPhaseModel : IId
{
string ExecutionPhaseName { get; }
string ImplementerFIO { get; }
ExecutionPhaseStatus Status { get; }
int WorkerId { get; }
}
}

View File

@ -0,0 +1,15 @@
namespace FactoryDataModels.Models
{
public interface IMachineModel : IId
{
string MachineName { get; }
DateTime ExploitationStartDate { get; }
int Lifetime { get; }
int WorkerId { get; }
Dictionary<int, (IPlanProductionModel, int)> MachinePlanProductions { get; }
}
}

View File

@ -0,0 +1,17 @@
namespace FactoryDataModels.Models
{
public interface IPlanProductionModel : IId
{
int ExecutionPhaseId { get; }
int WorkerId { get; }
string ProductionName { get; }
int Count { get; }
DateTime Deadline { get; }
Dictionary<int, (IWorkpieceModel, int)> PlanProductionWorkpieces { get; }
}
}

View File

@ -0,0 +1,15 @@
namespace FactoryDataModels.Models
{
public interface IProductModel : IId
{
string ProductName { get; }
double Price { get;}
int WorkerId { get; }
int RequirementId { get; }
Dictionary<int, (IMachineModel, int)> ProductMachines { get; }
}
}

View File

@ -0,0 +1,13 @@
namespace FactoryDataModels.Models
{
public interface IRequirementModel : IId
{
string RequirementName { get; }
string Description { get; }
int Lifetime { get; }
int WorkerId { get; }
}
}

View File

@ -0,0 +1,15 @@
using FactoryDataModels.Enums;
namespace FactoryDataModels.Models
{
public interface IWorkerModel : IId
{
string Login { get; }
string Email { get; }
string Password { get; }
WorkerRole Role { get; }
}
}

View File

@ -0,0 +1,15 @@
namespace FactoryDataModels.Models
{
public interface IWorkpieceModel : IId
{
string WorkpieceName { get; }
string Material { get; }
double Cost { get; }
int WorkerId { get; }
Dictionary<int, (IProductModel, int)> WorkpieceProducts { get; }
}
}

View File

@ -0,0 +1,10 @@
{
"profiles": {
"FactoryDataModels": {
"commandName": "Project"
},
"Профиль 1": {
"commandName": "Project"
}
}
}

View File

@ -0,0 +1,20 @@
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement
{
public class FactoryDatabase : DbContext
{
public virtual DbSet<Worker> Worker { set; get; }
public virtual DbSet<ExecutionPhase> ExecutionPhases { set; get; }
public virtual DbSet<MachinePlanProduction> MachinePlanProductions { set; get; }
public virtual DbSet<PlanProduction> PlanProductions { set; get; }
public virtual DbSet<PlanProductionWorkpiece> PlanProductionWorkpieces { set; get; }
public virtual DbSet<Workpiece> Workpieces { set; get; }
public virtual DbSet<WorkpieceProduct> WorkpieceProducts { set; get; }
public virtual DbSet<Machine> Machines { set; get; }
public virtual DbSet<ProductMachine> ProductMachines { set; get; }
public virtual DbSet<Product> Products { set; get; }
public virtual DbSet<Requirement> Requirements { set; get; }
}
}

View File

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.22" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FactoryContracts\FactoryContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,87 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement.Implements
{
public class ExecutionPhaseStorage : IExecutionPhaseStorage
{
public List<ExecutionPhaseViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.ExecutionPhases
.Include(x => x.Worker)
.Select(x => x.GetViewModel)
.ToList();
}
public List<ExecutionPhaseViewModel> GetFilteredList(ExecutionPhaseSearchModel model)
{
if (string.IsNullOrEmpty(model.ExecutionPhaseName))
{
return new();
}
using var context = new FactoryDatabase();
return context.ExecutionPhases
.Include(x => x.Worker)
.Where(x => x.ExecutionPhaseName.Contains(model.ExecutionPhaseName))
.Select(x => x.GetViewModel)
.ToList();
}
public ExecutionPhaseViewModel? GetElement(ExecutionPhaseSearchModel model)
{
if (string.IsNullOrEmpty(model.ExecutionPhaseName) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.ExecutionPhases.Include(x => x.Worker)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ExecutionPhaseName) && x.ExecutionPhaseName == model.ExecutionPhaseName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ExecutionPhaseViewModel? Insert(ExecutionPhaseBindingModel model)
{
var newExecutionPhase = ExecutionPhase.Create(model);
if (newExecutionPhase == null)
{
return null;
}
using var context = new FactoryDatabase();
context.ExecutionPhases.Add(newExecutionPhase);
context.SaveChanges();
return newExecutionPhase.GetViewModel;
}
public ExecutionPhaseViewModel? Update(ExecutionPhaseBindingModel model)
{
using var context = new FactoryDatabase();
var component = context.ExecutionPhases.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public ExecutionPhaseViewModel? Delete(ExecutionPhaseBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.ExecutionPhases.Include(x => x.Worker).FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.ExecutionPhases.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,109 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement.Implements
{
public class MachineStorage : IMachineStorage
{
public List<MachineViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.Machines
.Include(x => x.Worker)
.Include(x => x.PlanProductions)
.ThenInclude(x => x.PlanProduction)
.Select(x => x.GetViewModel)
.ToList();
}
public List<MachineViewModel> GetFilteredList(MachineSearchModel model)
{
if (string.IsNullOrEmpty(model.MachineName))
{
return new();
}
using var context = new FactoryDatabase();
return context.Machines
.Include(x => x.Worker)
.Include(x => x.PlanProductions)
.ThenInclude(x => x.PlanProduction)
.Where(x => x.MachineName.Contains(model.MachineName))
.Select(x => x.GetViewModel)
.ToList();
}
public MachineViewModel? GetElement(MachineSearchModel model)
{
if (string.IsNullOrEmpty(model.MachineName) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.Machines
.Include(x => x.Worker)
.Include(x => x.PlanProductions)
.ThenInclude(x => x.PlanProduction)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.MachineName) && x.MachineName == model.MachineName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public MachineViewModel? Insert(MachineBindingModel model)
{
using var context = new FactoryDatabase();
var newMachine = Machine.Create(context, model);
if (newMachine == null)
{
return null;
}
context.Machines.Add(newMachine);
context.SaveChanges();
return newMachine.GetViewModel;
}
public MachineViewModel? Update(MachineBindingModel model)
{
using var context = new FactoryDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var machine = context.Machines.FirstOrDefault(rec => rec.Id == model.Id);
if (machine == null)
{
return null;
}
machine.Update(model);
context.SaveChanges();
machine.UpdatePlanProductions(context, model);
transaction.Commit();
return machine.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public MachineViewModel? Delete(MachineBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.Machines
.Include(x => x.Worker)
.Include(x => x.PlanProductions)
.ThenInclude(x => x.PlanProduction)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Machines.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,116 @@
using Microsoft.EntityFrameworkCore;
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
namespace FactoryDatabaseImplement.Implements
{
public class PlanProductionStorage : IPlanProductionStorage
{
public PlanProductionViewModel? Delete(PlanProductionBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.PlanProductions
.Include(x => x.Worker)
.Include(x => x.ExecutionPhase)
.Include(x => x.Workpieces)
.ThenInclude( x => x.Workpiece)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.PlanProductions.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public PlanProductionViewModel? GetElement(PlanProductionSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
if (model.Id.HasValue)
return context.PlanProductions
.Include(x => x.Worker)
.Include(x => x.ExecutionPhase)
.Include(x =>x.Workpieces)
.ThenInclude(x => x.Workpiece)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
return null;
}
public List<PlanProductionViewModel> GetFilteredList(PlanProductionSearchModel model)
{
using var context = new FactoryDatabase();
if (model.Id.HasValue)
{
return context.PlanProductions
.Where(x => x.Id == model.Id)
.Include(x => x.Worker)
.Include(x => x.ExecutionPhase)
.Include(x => x.Workpieces)
.ThenInclude(x => x.Workpiece)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public List<PlanProductionViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.PlanProductions
.Include (x => x.Worker)
.Include(x => x.ExecutionPhase)
.Include(x => x.Workpieces)
.ThenInclude(x => x.Workpiece)
.ToList()
.Select(x =>x.GetViewModel)
.ToList();
}
public PlanProductionViewModel? Insert(PlanProductionBindingModel model)
{
using var context = new FactoryDatabase();
var newPlanProduction = PlanProduction.Create(context, model);
if (newPlanProduction == null)
{
return null;
}
context.PlanProductions.Add(newPlanProduction);
context.SaveChanges();
return newPlanProduction.GetViewModel;
}
public PlanProductionViewModel? Update(PlanProductionBindingModel model)
{
using var context = new FactoryDatabase();
var order = context.PlanProductions
.Include(x => x.Worker)
.Include(x => x.ExecutionPhase)
.Include(x => x.Workpieces)
.ThenInclude(x => x.Workpiece)
.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
return order.GetViewModel;
}
}
}

View File

@ -0,0 +1,113 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement.Implements
{
public class ProductStorage : IProductStorage
{
public List<ProductViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.Products
.Include(x => x.Worker)
.Include(x => x.Requirement)
.Include(x => x.Machines)
.ThenInclude(x => x.Machine)
.Select(x => x.GetViewModel)
.ToList();
}
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName))
{
return new();
}
using var context = new FactoryDatabase();
return context.Products
.Include(x => x.Worker)
.Include(x => x.Requirement)
.Include(x => x.Machines)
.ThenInclude(x => x.Machine)
.Where(x => x.ProductName.Contains(model.ProductName))
.Select(x => x.GetViewModel)
.ToList();
}
public ProductViewModel? GetElement(ProductSearchModel model)
{
if (string.IsNullOrEmpty(model.ProductName) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.Products
.Include(x => x.Worker)
.Include(x => x.Requirement)
.Include(x => x.Machines)
.ThenInclude(x => x.Machine)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProductName) && x.ProductName == model.ProductName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ProductViewModel? Insert(ProductBindingModel model)
{
using var context = new FactoryDatabase();
var newProduct = Product.Create(context, model);
if (newProduct == null)
{
return null;
}
context.Products.Add(newProduct);
context.SaveChanges();
return newProduct.GetViewModel;
}
public ProductViewModel? Update(ProductBindingModel model)
{
using var context = new FactoryDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var machine = context.Products.FirstOrDefault(rec => rec.Id == model.Id);
if (machine == null)
{
return null;
}
machine.Update(model);
context.SaveChanges();
machine.UpdateMachines(context, model);
transaction.Commit();
return machine.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ProductViewModel? Delete(ProductBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.Products
.Include(x => x.Worker)
.Include(x => x.Requirement)
.Include(x => x.Machines)
.ThenInclude(x => x.Machine)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Products.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,88 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement.Implements
{
public class RequirementStorage : IRequirementStorage
{
public List<RequirementViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.Requirements
.Include(x => x.Worker)
.Select(x => x.GetViewModel)
.ToList();
}
public List<RequirementViewModel> GetFilteredList(RequirementSearchModel model)
{
if (string.IsNullOrEmpty(model.RequirementName))
{
return new();
}
using var context = new FactoryDatabase();
return context.Requirements
.Include(x => x.Worker)
.Where(x => x.RequirementName.Contains(model.RequirementName))
.Select(x => x.GetViewModel)
.ToList();
}
public RequirementViewModel? GetElement(RequirementSearchModel model)
{
if (string.IsNullOrEmpty(model.RequirementName) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.Requirements
.Include(x => x.Worker)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.RequirementName) && x.RequirementName == model.RequirementName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public RequirementViewModel? Insert(RequirementBindingModel model)
{
var newRequirement = Requirement.Create(model);
if (newRequirement == null)
{
return null;
}
using var context = new FactoryDatabase();
context.Requirements.Add(newRequirement);
context.SaveChanges();
return newRequirement.GetViewModel;
}
public RequirementViewModel? Update(RequirementBindingModel model)
{
using var context = new FactoryDatabase();
var component = context.Requirements.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public RequirementViewModel? Delete(RequirementBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.Requirements.Include(x => x.Worker).FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Requirements.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,84 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
namespace FactoryDatabaseImplement.Implements
{
public class WorkerStorage : IWorkerStorage
{
public List<WorkerViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.Worker
.Select(x => x.GetViewModel)
.ToList();
}
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
{
if (string.IsNullOrEmpty(model.Login))
{
return new();
}
using var context = new FactoryDatabase();
return context.Worker
.Where(x => x.Login.Contains(model.Login))
.Select(x => x.GetViewModel)
.ToList();
}
public WorkerViewModel? GetElement(WorkerSearchModel model)
{
if (string.IsNullOrEmpty(model.Login) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.Worker
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public WorkerViewModel? Insert(WorkerBindingModel model)
{
var newWorker = Worker.Create(model);
if (newWorker == null)
{
return null;
}
using var context = new FactoryDatabase();
context.Worker.Add(newWorker);
context.SaveChanges();
return newWorker.GetViewModel;
}
public WorkerViewModel? Update(WorkerBindingModel model)
{
using var context = new FactoryDatabase();
var component = context.Worker.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public WorkerViewModel? Delete(WorkerBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.Worker.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Worker.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,109 @@
using FactoryContracts.BindingModels;
using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts;
using FactoryContracts.ViewModels;
using FactoryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace FactoryDatabaseImplement.Implements
{
public class WorkpieceStorage : IWorkpieceStorage
{
public List<WorkpieceViewModel> GetFullList()
{
using var context = new FactoryDatabase();
return context.Workpieces
.Include(x => x.Worker)
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model)
{
if (string.IsNullOrEmpty(model.WorkpieceName))
{
return new();
}
using var context = new FactoryDatabase();
return context.Workpieces
.Include(x => x.Worker)
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.Where(x => x.WorkpieceName.Contains(model.WorkpieceName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public WorkpieceViewModel? GetElement(WorkpieceSearchModel model)
{
if (string.IsNullOrEmpty(model.WorkpieceName) && !model.Id.HasValue)
{
return null;
}
using var context = new FactoryDatabase();
return context.Workpieces
.Include(x => x.Worker)
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkpieceName) && x.WorkpieceName == model.WorkpieceName) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public WorkpieceViewModel? Insert(WorkpieceBindingModel model)
{
using var context = new FactoryDatabase();
var newWorkpiece = Workpiece.Create(context, model);
if (newWorkpiece == null)
{
return null;
}
context.Workpieces.Add(newWorkpiece);
context.SaveChanges();
return newWorkpiece.GetViewModel;
}
public WorkpieceViewModel? Update(WorkpieceBindingModel model)
{
using var context = new FactoryDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var work = context.Workpieces.FirstOrDefault(rec => rec.Id == model.Id);
if (work == null)
{
return null;
}
work.Update(model);
context.SaveChanges();
work.UpdateProducts(context, model);
transaction.Commit();
return work.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public WorkpieceViewModel? Delete(WorkpieceBindingModel model)
{
using var context = new FactoryDatabase();
var element = context.Workpieces.Include(x => x.Worker)
.Include(x => x.Products)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Workpieces.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,76 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Enums;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class ExecutionPhase : IExecutionPhaseModel
{
public int Id { get; private set; }
[Required]
public int WorkerId { get; private set; }
public virtual Worker Worker { get; private set; } = new();
[Required]
public string ExecutionPhaseName { get; private set; } = string.Empty;
[Required]
public string ImplementerFIO { get; private set; } = string.Empty;
[Required]
public ExecutionPhaseStatus Status { get; private set; } = ExecutionPhaseStatus.Неизвестен;
[ForeignKey("ExecutionPhaseId")]
public virtual List<PlanProduction> PlanProductions { get; set; } = new();
public static ExecutionPhase? Create(ExecutionPhaseBindingModel model)
{
if (model == null)
{
return null;
}
return new ExecutionPhase()
{
Id = model.Id,
ExecutionPhaseName = model.ExecutionPhaseName,
ImplementerFIO = model.ImplementerFIO,
WorkerId = model.WorkerId,
Status = model.Status,
};
}
public static ExecutionPhase Create(ExecutionPhaseViewModel model)
{
return new ExecutionPhase
{
Id = model.Id,
ExecutionPhaseName = model.ExecutionPhaseName,
ImplementerFIO = model.ImplementerFIO,
WorkerId = model.WorkerId,
Status = model.Status,
};
}
public void Update(ExecutionPhaseBindingModel model)
{
if (model == null)
{
return;
}
ExecutionPhaseName = model.ExecutionPhaseName;
ImplementerFIO = model.ImplementerFIO;
Status = model.Status;
}
public ExecutionPhaseViewModel GetViewModel => new()
{
Id = Id,
ExecutionPhaseName = ExecutionPhaseName,
ImplementerFIO = ImplementerFIO,
WorkerId = WorkerId,
WorkerLogin = Worker.Login,
Status = Status,
};
}
}

View File

@ -0,0 +1,116 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class Machine : IMachineModel
{
public int Id { get; private set; }
[Required]
public int WorkerId { get; private set; }
public virtual Worker Worker { get; private set; } = new();
[Required]
public string MachineName { get; private set; } = string.Empty;
[Required]
public DateTime ExploitationStartDate { get; private set; } = DateTime.Now;
[Required]
public int Lifetime { get; private set; }
private Dictionary<int, (IPlanProductionModel, int)> _machinePlanProductions = null;
[NotMapped]
public Dictionary<int, (IPlanProductionModel, int)> MachinePlanProductions
{
get
{
if (_machinePlanProductions == null)
{
_machinePlanProductions = PlanProductions
.ToDictionary(recPC => recPC.PlanProductionId, recPC => (recPC.PlanProduction as IPlanProductionModel, recPC.Count));
}
return _machinePlanProductions;
}
}
[ForeignKey("MachineId")]
public virtual List<MachinePlanProduction> PlanProductions { get; private set; } = new();
[ForeignKey("MachineId")]
public virtual List<ProductMachine> Products { get; private set; } = new();
public static Machine Create(FactoryDatabase context, MachineBindingModel model)
{
if (model == null)
{
return null;
}
return new Machine()
{
Id = model.Id,
WorkerId = model.WorkerId,
MachineName = model.MachineName,
ExploitationStartDate = model.ExploitationStartDate,
Lifetime = model.Lifetime,
PlanProductions = model.MachinePlanProductions.Select(x => new MachinePlanProduction
{
PlanProduction = context.PlanProductions.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(MachineBindingModel model)
{
if (model == null)
{
return;
}
MachineName = model.MachineName;
}
public MachineViewModel GetViewModel => new()
{
Id = Id,
WorkerId = WorkerId,
MachineName = MachineName,
ExploitationStartDate = ExploitationStartDate,
Lifetime = Lifetime,
WorkerLogin = Worker.Login,
MachinePlanProductions = MachinePlanProductions,
};
public void UpdatePlanProductions(FactoryDatabase context, MachineBindingModel model)
{
var machinePlanProductions = context.MachinePlanProductions.Where(rec => rec.MachineId == model.Id).ToList();
if (machinePlanProductions != null && machinePlanProductions.Count > 0)
{
context.MachinePlanProductions.RemoveRange(machinePlanProductions.Where(rec => !model.MachinePlanProductions.ContainsKey(rec.PlanProductionId)));
context.SaveChanges();
foreach (var updatePlanProduction in machinePlanProductions)
{
updatePlanProduction.Count = model.MachinePlanProductions[updatePlanProduction.PlanProductionId].Item2;
model.MachinePlanProductions.Remove(updatePlanProduction.PlanProductionId);
}
context.SaveChanges();
}
var machine = context.Machines.First(x => x.Id == Id);
foreach (var pc in model.MachinePlanProductions)
{
context.MachinePlanProductions.Add(new MachinePlanProduction
{
Machine = machine,
PlanProduction = context.PlanProductions.First(x => x.Id == pc.Key),
Count = pc.Value.Item2
});
context.SaveChanges();
}
_machinePlanProductions = null;
}
}
}

View File

@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace FactoryDatabaseImplement.Models
{
public class MachinePlanProduction
{
public int Id { get; set; }
[Required]
public int MachineId { get; set; }
[Required]
public int PlanProductionId { get; set; }
[Required]
public int Count { get; set; }
public virtual PlanProduction PlanProduction { get; set; } = new();
public virtual Machine Machine { get; set; } = new();
}
}

View File

@ -0,0 +1,122 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class PlanProduction : IPlanProductionModel
{
public int Id { get; private set; }
[Required]
public int ExecutionPhaseId { get; private set; }
public virtual ExecutionPhase ExecutionPhase { get; private set; } = new();
[Required]
public int WorkerId { get; private set; }
public virtual Worker Worker { get; private set; } = new();
[Required]
public string ProductionName { get; private set; } = string.Empty;
[Required]
public int Count { get; private set; }
[Required]
public DateTime Deadline { get; private set; }
private Dictionary<int, (IWorkpieceModel, int)>? _planProductionWorkpieces = null;
[NotMapped]
public Dictionary<int, (IWorkpieceModel, int)> PlanProductionWorkpieces
{
get
{
if (_planProductionWorkpieces == null)
{
_planProductionWorkpieces = Workpieces
.ToDictionary(recPC => recPC.WorkpieceId, recPC => (recPC.Workpiece as IWorkpieceModel, recPC.Count));
}
return _planProductionWorkpieces;
}
}
[ForeignKey("PlanProductionId")]
public virtual List<PlanProductionWorkpiece> Workpieces{ get; set; } = new();
[ForeignKey("PlanProductionId")]
public virtual List<MachinePlanProduction> Machines { get; set; } = new();
public static PlanProduction Create(FactoryDatabase context, PlanProductionBindingModel model)
{
if (model == null)
{
return null;
}
return new PlanProduction()
{
Id = model.Id,
WorkerId = model.WorkerId,
Count = model.Count,
ExecutionPhaseId = model.ExecutionPhaseId,
ProductionName = model.ProductionName,
Deadline = model.Deadline,
Workpieces = model.PlanProductionWorkpieces.Select(x => new PlanProductionWorkpiece
{
Workpiece = context.Workpieces.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(PlanProductionBindingModel model)
{
if (model == null)
{
return;
}
Count = model.Count;
ExecutionPhaseId = model.ExecutionPhaseId;
ProductionName = model.ProductionName;
Deadline = model.Deadline;
}
public PlanProductionViewModel GetViewModel => new()
{
Id = Id,
WorkerId = WorkerId,
WorkerLogin = Worker.Login,
ExecutionPhaseId = ExecutionPhaseId,
ExecutionPhaseName = ExecutionPhase.ExecutionPhaseName,
ProductionName = ProductionName,
Deadline = Deadline,
Count = Count,
PlanProductionWorkpieces = PlanProductionWorkpieces
};
public void UpdateWorkpieces(FactoryDatabase context, PlanProductionBindingModel model)
{
var planProductionWorkpieces = context.PlanProductionWorkpieces.Where(rec => rec.PlanProductionId == model.Id).ToList();
if (planProductionWorkpieces != null && planProductionWorkpieces.Count > 0)
{
context.PlanProductionWorkpieces.RemoveRange(planProductionWorkpieces.Where(rec => !model.PlanProductionWorkpieces.ContainsKey(rec.WorkpieceId)));
context.SaveChanges();
foreach (var updateWorkpiece in planProductionWorkpieces)
{
updateWorkpiece.Count = model.PlanProductionWorkpieces[updateWorkpiece.WorkpieceId].Item2;
model.PlanProductionWorkpieces.Remove(updateWorkpiece.WorkpieceId);
}
context.SaveChanges();
}
var plan = context.PlanProductions.First(x => x.Id == Id);
foreach (var pc in model.PlanProductionWorkpieces)
{
context.PlanProductionWorkpieces.Add(new PlanProductionWorkpiece
{
PlanProduction = plan,
Workpiece = context.Workpieces.First(x => x.Id == pc.Key),
Count = pc.Value.Item2
});
context.SaveChanges();
}
_planProductionWorkpieces = null;
}
}
}

View File

@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace FactoryDatabaseImplement.Models
{
public class PlanProductionWorkpiece
{
public int Id { get; set; }
[Required]
public int PlanProductionId { get; set; }
[Required]
public int WorkpieceId { get; set; }
[Required]
public int Count { get; set; }
public virtual PlanProduction PlanProduction { get; set; } = new();
public virtual Workpiece Workpiece { get; set; } = new();
}
}

View File

@ -0,0 +1,120 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class Product : IProductModel
{
public int Id { get; private set; }
[Required]
public int WorkerId { get; private set; }
public virtual Worker Worker { get; private set; } = new();
[Required]
public int RequirementId { get; private set; }
public virtual Requirement Requirement { get; private set; } = new();
[Required]
public string ProductName { get; private set; } = string.Empty;
public double Price { get; private set; }
private Dictionary<int, (IMachineModel, int)> _productMachines = null;
[NotMapped]
public Dictionary<int, (IMachineModel, int)> ProductMachines
{
get
{
if (_productMachines == null)
{
_productMachines = Machines
.ToDictionary(recPC => recPC.MachineId, recPC => (recPC.Machine as IMachineModel, recPC.Count));
}
return _productMachines;
}
}
[ForeignKey("ProductId")]
public virtual List<ProductMachine> Machines { get; private set; } = new();
[ForeignKey("ProductId")]
public virtual List<WorkpieceProduct> Workpieces { get; private set; } = new();
public static Product Create(FactoryDatabase context, ProductBindingModel model)
{
if (model == null)
{
return null;
}
return new Product()
{
Id = model.Id,
WorkerId = model.WorkerId,
RequirementId = model.RequirementId,
ProductName = model.ProductName,
Price = model.Price,
Machines = model.ProductMachines.Select(x => new ProductMachine
{
Machine = context.Machines.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(ProductBindingModel model)
{
if (model == null)
{
return;
}
ProductName = model.ProductName;
Price = model.Price;
}
public ProductViewModel GetViewModel => new()
{
Id = Id,
WorkerId = WorkerId,
RequirementId = RequirementId,
ProductName = ProductName,
WorkerLogin = Worker.Login,
RequirementName = Requirement.RequirementName,
Price = Price,
ProductMachines = ProductMachines,
};
public void UpdateMachines(FactoryDatabase context, ProductBindingModel model)
{
var productMachines = context.ProductMachines.Where(rec => rec.ProductId == model.Id).ToList();
if (productMachines != null && productMachines.Count > 0)
{
context.ProductMachines.RemoveRange(productMachines.Where(rec => !model.ProductMachines.ContainsKey(rec.MachineId)));
context.SaveChanges();
foreach (var updateMachine in productMachines)
{
updateMachine.Count = model.ProductMachines[updateMachine.MachineId].Item2;
model.ProductMachines.Remove(updateMachine.MachineId);
}
context.SaveChanges();
}
var machine = context.Machines.First(x => x.Id == Id);
foreach (var pc in model.ProductMachines)
{
context.ProductMachines.Add(new ProductMachine
{
Product = context.Products.First(x => x.Id == pc.Key),
Machine = machine,
Count = pc.Value.Item2
});
context.SaveChanges();
}
_productMachines = null;
}
}
}

View File

@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace FactoryDatabaseImplement.Models
{
public class ProductMachine
{
public int Id { get; set; }
[Required]
public int ProductId { get; set; }
public virtual Product Product { get; set; } = new();
[Required]
public int MachineId { get; set; }
public virtual Machine Machine { get; set; } = new();
[Required]
public int Count { get; set; }
}
}

View File

@ -0,0 +1,65 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class Requirement : IRequirementModel
{
public int Id { get; private set; }
[Required]
public int WorkerId { get; private set; }
public virtual Worker Worker { get; private set; } = new();
[Required]
public string RequirementName { get; private set; } = string.Empty;
[Required]
public string Description { get; private set; } = string.Empty;
[Required]
public int Lifetime { get; private set; }
[ForeignKey("RequirementId")]
public virtual Product Product { get; private set; } = new();
public static Requirement Create(RequirementBindingModel model)
{
if (model == null)
{
return null;
}
return new Requirement()
{
Id = model.Id,
RequirementName = model.RequirementName,
Description = model.Description,
Lifetime = model.Lifetime,
WorkerId = model.WorkerId,
};
}
public void Update(RequirementBindingModel model)
{
if (model == null)
{
return;
}
RequirementName = model.RequirementName;
Description = model.Description;
}
public RequirementViewModel GetViewModel => new()
{
Id = Id,
WorkerId = WorkerId,
RequirementName = RequirementName,
Lifetime = Lifetime,
WorkerLogin = Worker.Login,
};
}
}

View File

@ -0,0 +1,80 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Enums;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class Worker : IWorkerModel
{
public int Id { get; private set; }
[Required]
public string Login { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[Required]
public string Password { get; private set; } = string.Empty;
public WorkerRole Role { get; private set; } = WorkerRole.Неизвестен;
[ForeignKey("WorkerId")]
public virtual List<ExecutionPhase> ExecutionPhases{ get; set; } = new();
[ForeignKey("WorkerId")]
public virtual List<PlanProduction> PlanProductions { get; set; } = new();
[ForeignKey("WorkerId")]
public virtual List<Workpiece> Workpieces { get; set; } = new();
public static Worker? Create(WorkerBindingModel model)
{
if (model == null)
{
return null;
}
return new Worker()
{
Id = model.Id,
Login = model.Login,
Email= model.Email,
Password = model.Password,
Role = model.Role,
};
}
public static Worker Create(WorkerViewModel model)
{
return new Worker
{
Id = model.Id,
Login = model.Login,
Email = model.Email,
Password = model.Password,
Role = model.Role,
};
}
public void Update(WorkerBindingModel model)
{
if (model == null)
{
return;
}
Login = model.Login;
Email = model.Email;
Password = model.Password;
}
public WorkerViewModel GetViewModel => new()
{
Id = Id,
Login = Login,
Email = Email,
Password = Password,
Role = Role,
};
}
}

View File

@ -0,0 +1,108 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FactoryDatabaseImplement.Models
{
public class Workpiece : IWorkpieceModel
{
public int Id { get; set; }
[Required]
public string WorkpieceName { get; set; } = string.Empty;
[Required]
public int WorkerId { get; set; }
public virtual Worker Worker { get; set; } = new Worker();
[Required]
public string Material { get; set; } = string.Empty;
[Required]
public double Cost { get; set; }
private Dictionary<int, (IProductModel, int)>? _workpieceProducts = null;
[NotMapped]
public Dictionary<int, (IProductModel, int)> WorkpieceProducts
{
get
{
if (_workpieceProducts == null)
{
_workpieceProducts = Products
.ToDictionary(recPC => recPC.ProductId, recPC => (recPC.Product as IProductModel, recPC.Count));
}
return _workpieceProducts;
}
}
[ForeignKey("WorkpieceId")]
public virtual List<WorkpieceProduct> Products { get; set; } = new();
[ForeignKey("WorkpieceId")]
public virtual List<PlanProductionWorkpiece> PlanProductions { get; set; } = new();
public static Workpiece Create(FactoryDatabase context, WorkpieceBindingModel model)
{
return new Workpiece()
{
Id = model.Id,
WorkpieceName = model.WorkpieceName,
Cost = model.Cost,
Material = model.Material,
WorkerId = model.WorkerId,
Products = model.WorkpieceProducts.Select(x => new WorkpieceProduct
{
Product = context.Products.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(WorkpieceBindingModel model)
{
WorkpieceName = model.WorkpieceName;
Cost = model.Cost;
Material = model.Material;
}
public WorkpieceViewModel GetViewModel => new()
{
Id = Id,
WorkpieceName = WorkpieceName,
Cost = Cost,
Material = Material,
WorkerId = WorkerId,
WorkerLogin = Worker.Login,
WorkpieceProducts = WorkpieceProducts
};
public void UpdateProducts(FactoryDatabase context, WorkpieceBindingModel model)
{
var workpieceProducts = context.WorkpieceProducts.Where(rec => rec.WorkpieceId == model.Id).ToList();
if (workpieceProducts != null && workpieceProducts.Count > 0)
{
context.WorkpieceProducts.RemoveRange(workpieceProducts.Where(rec => !model.WorkpieceProducts.ContainsKey(rec.ProductId)));
context.SaveChanges();
foreach (var updateProduct in workpieceProducts)
{
updateProduct.Count = model.WorkpieceProducts[updateProduct.ProductId].Item2;
model.WorkpieceProducts.Remove(updateProduct.ProductId);
}
context.SaveChanges();
}
var workpiece = context.Workpieces.First(x => x.Id == Id);
foreach (var pc in model.WorkpieceProducts)
{
context.WorkpieceProducts.Add(new WorkpieceProduct
{
Workpiece = workpiece,
Product = context.Products.First(x => x.Id == pc.Key),
Count = pc.Value.Item2
});
context.SaveChanges();
}
_workpieceProducts = null;
}
}
}

View File

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
namespace FactoryDatabaseImplement.Models
{
public class WorkpieceProduct
{
public int Id { get; set; }
[Required]
public int WorkpieceId { get; set; }
[Required]
public int ProductId { get; set; }
[Required]
public int Count { get; set; }
public virtual Product Product { get; set; } = new();
public virtual Workpiece Workpiece { get; set; } = new();
}
}

View File

@ -0,0 +1,49 @@
using FactoryContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace FactoryWorkerApp
{
public class APIWorker
{
private static readonly HttpClient _worker = new();
public static WorkerViewModel? Worker { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_worker.BaseAddress = new Uri(configuration["IPAddress"]);
_worker.DefaultRequestHeaders.Accept.Clear();
_worker.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _worker.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
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 = _worker.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -0,0 +1,76 @@
using FactoryContracts.BindingModels;
using FactoryContracts.ViewModels;
using FactoryWorkerApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace FactoryWorkerApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
if (APIWorker.Worker == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Privacy(string email, string password, string login)
{
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Enter(string login, string password)
{
}
[HttpGet]
public IActionResult Register()
{
return View();
}
[HttpPost]
public void Register(string email, string password, string login)
{
}
[HttpGet]
public IActionResult Create()
{
ViewBag.works = APIWorker.GetRequest<List<ProductViewModel>>("api/main/getproductlist");
return View();
}
[HttpPost]
public void Create(string name, double cost, string material)
{
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FactoryDatabaseImplement\FactoryDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
namespace FactoryWorkerApp.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,30 @@
using FactoryWorkerApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIWorker.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:30752",
"sslPort": 44368
}
},
"profiles": {
"FactoryWorkerApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7012",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,29 @@
@using FactoryContracts.ViewModels
@{
ViewData["Title"] = "Home Page";
}
<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="Workpieces">Заготовки</a>
<a asp-action="PlanProductions">Планы производства</a>
<a asp-action="PlanProdctionExecutionPhase">Привзяка планов производства к заготовкам</a>
<a asp-action="ExecutionPhases">Этапы выполнения</a>
<a asp-action="Reports">Получение списка</a>
</p>
}
</div>

View File

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace FactoryWorkerApp.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,29 @@
@{
ViewData["Title"] = "Register";
}
<div class="text-center">
<h2 class="display-4">Регистрация</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пoчта:</div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-4">Подтверждение пароля:</div>
<div class="col-8"><input type="password" name="passwordConfirm" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,26 @@
@{
ViewData["Title"] = "Workpiece";
}
<div class="text-center">
<h2 class="display-4">Заготовка</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Изделие:</div>
<div class="col-8">
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"Id", "ProductName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Материал:</div>
<div class="col-8"><input type="text" name="material" id="count" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="text" id="cost" name="cost" readonly /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,63 @@
@using FactoryContracts.ViewModels
@model List<WorkpieceViewModel>
@{
ViewData["Title"] = "Workpieces";
}
<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="Workpiece">Создать заказ</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Название заготовки
</th>
<th>
Материал
</th>
<th>
Цена
</th>
<th>
Логин работника
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.WorkpieceName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Material)
</td>
<td>
@Html.DisplayFor(modelItem => item.Cost)
</td>
<td>
@Html.DisplayFor(modelItem => item.WorkerLogin)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,26 @@
@page
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace FactoryWorkerApp.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - FactoryWorkerApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/FactoryWorkerApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">FactoryWorkerApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - FactoryWorkerApp - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using FactoryWorkerApp
@namespace FactoryWorkerApp.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,12 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5012/"
}

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5012/"
}

View File

@ -0,0 +1,18 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2021 Twitter, Inc.
Copyright (c) 2011-2021 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More