From bc4efdc01aed3b1b2bdecc92b0bc9c28a3f21470 Mon Sep 17 00:00:00 2001 From: Yuee Shiness Date: Wed, 5 Apr 2023 19:26:00 +0400 Subject: [PATCH] Guarantor: DataModels + Binding/Search/View models. Contractor: DataModels. --- .../ComputerStoreContracts.csproj | 2 -- .../SearchModels/ComponentSearchModel.cs | 14 +++++++++++ .../SearchModels/PCSearchModel.cs | 14 +++++++++++ .../SearchModels/ProductSearchModel.cs | 14 +++++++++++ .../ViewModels/ComponentViewModel.cs | 23 +++++++++++++++++ .../ViewModels/PCViewModel.cs | 25 +++++++++++++++++++ .../ViewModels/ProductViewModel.cs | 25 +++++++++++++++++++ ComputerStoreDataModels/Enums/EmployeeRole.cs | 14 +++++++++++ ComputerStoreDataModels/Models/IUserModel.cs | 7 ++++-- 9 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 ComputerStoreContracts/SearchModels/ComponentSearchModel.cs create mode 100644 ComputerStoreContracts/SearchModels/PCSearchModel.cs create mode 100644 ComputerStoreContracts/SearchModels/ProductSearchModel.cs create mode 100644 ComputerStoreContracts/ViewModels/ComponentViewModel.cs create mode 100644 ComputerStoreContracts/ViewModels/PCViewModel.cs create mode 100644 ComputerStoreContracts/ViewModels/ProductViewModel.cs create mode 100644 ComputerStoreDataModels/Enums/EmployeeRole.cs diff --git a/ComputerStoreContracts/ComputerStoreContracts.csproj b/ComputerStoreContracts/ComputerStoreContracts.csproj index d3fb6d5..554642c 100644 --- a/ComputerStoreContracts/ComputerStoreContracts.csproj +++ b/ComputerStoreContracts/ComputerStoreContracts.csproj @@ -8,9 +8,7 @@ - - diff --git a/ComputerStoreContracts/SearchModels/ComponentSearchModel.cs b/ComputerStoreContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..e293df6 --- /dev/null +++ b/ComputerStoreContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? ID { get; set; } + public string? Name { get; set; } + } +} diff --git a/ComputerStoreContracts/SearchModels/PCSearchModel.cs b/ComputerStoreContracts/SearchModels/PCSearchModel.cs new file mode 100644 index 0000000..a3b1eee --- /dev/null +++ b/ComputerStoreContracts/SearchModels/PCSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.SearchModels +{ + public class PCSearchModel + { + public int? ID { get; set; } + public string? Name { get; set; } + } +} diff --git a/ComputerStoreContracts/SearchModels/ProductSearchModel.cs b/ComputerStoreContracts/SearchModels/ProductSearchModel.cs new file mode 100644 index 0000000..03a3cb5 --- /dev/null +++ b/ComputerStoreContracts/SearchModels/ProductSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.SearchModels +{ + public class ProductSearchModel + { + public int? ID { get; set; } + public string? Name { get; set; } + } +} diff --git a/ComputerStoreContracts/ViewModels/ComponentViewModel.cs b/ComputerStoreContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..22ef707 --- /dev/null +++ b/ComputerStoreContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,23 @@ +using ComputerStoreDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int ID {get; set;} + + [DisplayName("Component's name")] + public string Name { get; set; } = string.Empty; + + [DisplayName("Component's price")] + public double Price { get; set; } + + + } +} diff --git a/ComputerStoreContracts/ViewModels/PCViewModel.cs b/ComputerStoreContracts/ViewModels/PCViewModel.cs new file mode 100644 index 0000000..4ffb449 --- /dev/null +++ b/ComputerStoreContracts/ViewModels/PCViewModel.cs @@ -0,0 +1,25 @@ +using ComputerStoreDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.ViewModels +{ + public class PCViewModel : IPCModel + { + public int ID { get; set; } + + [DisplayName("PC's name")] + public string Name { get; set; } = string.Empty; + + [DisplayName("PC's price")] + public double Price { get; set; } + + public Dictionary PCComponents { get; set; } = new(); + + + } +} diff --git a/ComputerStoreContracts/ViewModels/ProductViewModel.cs b/ComputerStoreContracts/ViewModels/ProductViewModel.cs new file mode 100644 index 0000000..31a05bf --- /dev/null +++ b/ComputerStoreContracts/ViewModels/ProductViewModel.cs @@ -0,0 +1,25 @@ +using ComputerStoreDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreContracts.ViewModels +{ + public class ProductViewModel : IProductModel + { + public int ID {get; set;} + + [DisplayName("Product's name")] + public string Name { get; set; } = string.Empty; + + [DisplayName("Product's price")] + public double Price { get; set; } + + public Dictionary ProductComponents { get; set; } = new(); + + + } +} diff --git a/ComputerStoreDataModels/Enums/EmployeeRole.cs b/ComputerStoreDataModels/Enums/EmployeeRole.cs new file mode 100644 index 0000000..598f95f --- /dev/null +++ b/ComputerStoreDataModels/Enums/EmployeeRole.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerStoreDataModels.Enums +{ + public enum EmployeeRole + { + Guarantor = 0, + Cotnractor = 1 + } +} diff --git a/ComputerStoreDataModels/Models/IUserModel.cs b/ComputerStoreDataModels/Models/IUserModel.cs index 7c038bc..8dd5be4 100644 --- a/ComputerStoreDataModels/Models/IUserModel.cs +++ b/ComputerStoreDataModels/Models/IUserModel.cs @@ -1,5 +1,7 @@ -using System; +using ComputerStoreDataModels.Enums; +using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,6 +14,7 @@ namespace ComputerStoreDataModels.Models string Password { get; } string FirstName { get; } string LastName { get; } - string MiddleName { get; } + string MiddleName { get; } + EmployeeRole Role { get; } } }