From 59663ca6409941401a19e4120f9d97750075f3ab Mon Sep 17 00:00:00 2001 From: Zyzf Date: Wed, 5 Apr 2023 14:35:00 +0400 Subject: [PATCH] fixed models + view models --- .../ViewModels/FurnitureModuleViewModel.cs | 3 +- .../ViewModels/FurnitureViewModel.cs | 5 +-- .../ViewModels/MaterialViewModel.cs | 14 ++++++-- .../ViewModels/OrderViewModel.cs | 7 ++-- .../ViewModels/RoleViewModel.cs | 2 ++ .../ViewModels/ScopeViewModel.cs | 2 ++ .../ViewModels/SetViewModel.cs | 3 +- .../ViewModels/UserViewModel.cs | 5 +-- .../Models/IFurnitureModel.cs | 2 +- .../Models/IFurnitureModuleModel.cs | 2 +- .../Models/IMaterialModel.cs | 3 +- .../Models/IOrderModel.cs | 4 +-- .../Models/ISetModel.cs | 2 +- .../Models/IUserModel.cs | 2 +- ...ureAssembly_WorkerDatabaseImplement.csproj | 1 + .../Models/Role.cs | 33 +++++++++++++++++-- .../Models/User.cs | 24 ++++++++++++++ 17 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/User.cs diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureModuleViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureModuleViewModel.cs index 16e65c4..0663b35 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureModuleViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureModuleViewModel.cs @@ -17,8 +17,9 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public double Cost { get; set; } [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } + public int UserId { get; set; } [DisplayName("Изготовитель")] - public IUserModel User { get; set; } = new UserViewModel(); + public string UserName { get; set; } = string.Empty; public Dictionary FurnitureFurnitureModules { get; set; } = new(); } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureViewModel.cs index d190f70..da9b571 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/FurnitureViewModel.cs @@ -18,7 +18,8 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } public Dictionary FurnitureMaterials { get; set; } = new(); - [DisplayName("Менеджер")] - public IUserModel User { get; set; } = new UserViewModel(); + public int UserId { get; set; } + [DisplayName("Изготовитель")] + public string UserName { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/MaterialViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/MaterialViewModel.cs index cbc1c8a..f9a4f38 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/MaterialViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/MaterialViewModel.cs @@ -1,6 +1,7 @@ using FurnitureAssembly_WorkerDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,9 +10,16 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels { public class MaterialViewModel : IMaterialModel { - public string Name { get; set; } = string.Empty; - public double Cost { get; set; } - public IScopeModel scope { get; set; } = new ScopeViewModel(); public int Id { get; set; } + [DisplayName("Название материала")] + public string Name { get; set; } = string.Empty; + [DisplayName("Стоимость материала")] + public double Cost { get; set; } + public int ScopeId { get; set; } + [DisplayName("Область применения")] + public string ScopeName { get; set; } = string.Empty; + public int UserId { get; set; } + [DisplayName("Изготовитель")] + public string UserName { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/OrderViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/OrderViewModel.cs index 7273ab3..adbe6a6 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/OrderViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/OrderViewModel.cs @@ -17,10 +17,13 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public string CustomerName { get; set; } = string.Empty; [DisplayName("Тип оплаты")] public PaymentType PaymentType { get; set; } = PaymentType.Неизвестен; - public Dictionary OrderSets { get; set; } = new(); + public int SetId { get; set; } + [DisplayName("Гарнитур")] + public string SetName { get; set; } = string.Empty; [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } + public int UserId { get; set; } [DisplayName("Менеджер")] - public IUserModel User { get; set; } = new UserViewModel(); + public string UserName { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/RoleViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/RoleViewModel.cs index 01ac196..4e9d295 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/RoleViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/RoleViewModel.cs @@ -1,6 +1,7 @@ using FurnitureAssembly_WorkerDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,6 +11,7 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public class RoleViewModel : IRoleModel { public int Id { get; set; } + [DisplayName("Название роли")] public string Name { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/ScopeViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/ScopeViewModel.cs index 70c0b6e..9390d48 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/ScopeViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/ScopeViewModel.cs @@ -1,6 +1,7 @@ using FurnitureAssembly_WorkerDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,6 +11,7 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public class ScopeViewModel : IScopeModel { public int Id { get; set; } + [DisplayName("Название области применения")] public string Name { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/SetViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/SetViewModel.cs index d57f31a..3422501 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/SetViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/SetViewModel.cs @@ -17,8 +17,9 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public double Cost { get; set; } [DisplayName("Дата создания")] public DateTime DateCreate { get; set; } + public int UserId { get; set; } [DisplayName("Менеджер")] - public IUserModel User { get; set; } = new UserViewModel(); + public string UserName { get; set; } = string.Empty; public Dictionary SetFurnitureModules { get; set; } = new(); } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/UserViewModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/UserViewModel.cs index 69d3d68..a85b110 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/UserViewModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerContracts/ViewModels/UserViewModel.cs @@ -18,7 +18,8 @@ namespace FurnitureAssembly_WorkerContracts.ViewModels public string Login { get; set; } = string.Empty; [DisplayName("ФИО пользователя")] public string Name { get; set; } = string.Empty; - [DisplayName("Роль пользоватеоя")] - public IRoleModel Role { get; set; } = new RoleViewModel(); + public int RoleId { get; set; } + [DisplayName("Роль пользователя")] + public string RoleName { get; set; } = string.Empty; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModel.cs index e724573..2923468 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModel.cs @@ -12,6 +12,6 @@ namespace FurnitureAssembly_WorkerDataModels.Models double Cost { get; } DateTime DateCreate { get; } Dictionary FurnitureMaterials { get; } - IUserModel User { get; } + int UserId { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModuleModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModuleModel.cs index ec473e6..504fc3b 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModuleModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IFurnitureModuleModel.cs @@ -11,7 +11,7 @@ namespace FurnitureAssembly_WorkerDataModels.Models string Name { get; } double Cost { get; } DateTime DateCreate { get; } - IUserModel User { get; } + int UserId { get; } Dictionary FurnitureFurnitureModules { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IMaterialModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IMaterialModel.cs index 78adfc7..0d5c146 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IMaterialModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IMaterialModel.cs @@ -11,6 +11,7 @@ namespace FurnitureAssembly_WorkerDataModels.Models { string Name { get; } double Cost { get; } - IScopeModel scope { get; } + int ScopeId { get; } + int UserId { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IOrderModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IOrderModel.cs index 62c8adf..75bc09b 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IOrderModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IOrderModel.cs @@ -11,8 +11,8 @@ namespace FurnitureAssembly_WorkerDataModels.Models { string CustomerName { get; } PaymentType PaymentType { get; } - Dictionary OrderSets { get; } + int SetId { get; } + int UserId { get; } DateTime DateCreate { get; } - IUserModel User { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/ISetModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/ISetModel.cs index ef58075..28544b4 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/ISetModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/ISetModel.cs @@ -11,7 +11,7 @@ namespace FurnitureAssembly_WorkerDataModels.Models string Name { get; } double Cost { get; } DateTime DateCreate { get; } - IUserModel User { get; } + int UserId { get; } Dictionary SetFurnitureModules { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IUserModel.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IUserModel.cs index 699dd82..e1865e5 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IUserModel.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDataModels/Models/IUserModel.cs @@ -12,6 +12,6 @@ namespace FurnitureAssembly_WorkerDataModels.Models string Login { get; } string Password { get; } string Name { get; } - IRoleModel Role { get; } + int RoleId { get; } } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/FurnitureAssembly_WorkerDatabaseImplement.csproj b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/FurnitureAssembly_WorkerDatabaseImplement.csproj index d1c89a0..a04d36b 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/FurnitureAssembly_WorkerDatabaseImplement.csproj +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/FurnitureAssembly_WorkerDatabaseImplement.csproj @@ -17,6 +17,7 @@ + diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/Role.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/Role.cs index 76000e6..47e7ee7 100644 --- a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/Role.cs +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/Role.cs @@ -1,6 +1,9 @@ -using FurnitureAssembly_WorkerDataModels.Models; +using FurnitureAssembly_WorkerContracts.BindingModels; +using FurnitureAssembly_WorkerContracts.ViewModels; +using FurnitureAssembly_WorkerDataModels.Models; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,6 +13,32 @@ namespace FurnitureAssembly_WorkerDatabaseImplement.Models public class Role : IRoleModel { public int Id { get; set; } - public string Name => throw new NotImplementedException(); + [Required] + public string Name { get; set; } = string.Empty; + public static Role? Create(RoleBindingModel? model) + { + if (model == null) + { + return null; + } + return new Role() + { + Id = model.Id, + Name = model.Name + }; + } + public void Update(RoleBindingModel? model) + { + if (model == null) + { + return; + } + Name = model.Name; + } + public RoleViewModel GetViewModel => new() + { + Id = Id, + Name = Name + }; } } diff --git a/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/User.cs b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/User.cs new file mode 100644 index 0000000..5768d57 --- /dev/null +++ b/FurnitureAssembly_Worker/FurnitureAssembly_WorkerDatabaseImplement/Models/User.cs @@ -0,0 +1,24 @@ +using FurnitureAssembly_WorkerDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FurnitureAssembly_WorkerDatabaseImplement.Models +{ + public class User : IUserModel + { + public int Id { get; set; } + [Required] + public string Login { get; set; } = string.Empty; + [Required] + public string Password { get; set; } = string.Empty; + [Required] + public string Name { get; set; } = string.Empty; + [Required] + public int RoleId { get; set; } + public virtual Role Role { get; set; } + } +}