From cdff9cd481cf4104fa8e759b38bf68595693b26c Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 3 May 2024 10:59:33 +0400 Subject: [PATCH] add views --- .../AbstractModels/ISale.cs | 5 ++- .../CarShowroomDataModels/Dtos/SaleDto.cs | 30 ++++++++++++++ .../CarShowroomDataModels/Views/CarView.cs | 32 +++++++++++++++ .../CarShowroomDataModels/Views/ClientView.cs | 28 +++++++++++++ .../Views/EmployeeView.cs | 28 +++++++++++++ .../CarShowroomDataModels/Views/MakeView.cs | 22 ++++++++++ .../CarShowroomDataModels/Views/ModelView.cs | 29 +++++++++++++ .../CarShowroomDataModels/Views/SaleView.cs | 41 +++++++++++++++++++ .../Views/ServiceView.cs | 22 ++++++++++ 9 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 CarShowroom/CarShowroomDataModels/Dtos/SaleDto.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/CarView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/ClientView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/MakeView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/ModelView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/SaleView.cs create mode 100644 CarShowroom/CarShowroomDataModels/Views/ServiceView.cs diff --git a/CarShowroom/CarShowroomDataModels/AbstractModels/ISale.cs b/CarShowroom/CarShowroomDataModels/AbstractModels/ISale.cs index af0945e..fce93a2 100644 --- a/CarShowroom/CarShowroomDataModels/AbstractModels/ISale.cs +++ b/CarShowroom/CarShowroomDataModels/AbstractModels/ISale.cs @@ -1,4 +1,5 @@ -using System; +using CarShowroomDataModels.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ using System.Threading.Tasks; namespace CarShowroomContracts.AbstractModels { - internal interface ISale + internal interface ISale : IId { DateTime SaleTime { get; } int Cost { get; } diff --git a/CarShowroom/CarShowroomDataModels/Dtos/SaleDto.cs b/CarShowroom/CarShowroomDataModels/Dtos/SaleDto.cs new file mode 100644 index 0000000..cb4e814 --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Dtos/SaleDto.cs @@ -0,0 +1,30 @@ +using CarShowroomContracts.AbstractModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomDataModels.Dtos +{ + internal class SaleDto : ISale + { + public int Id { get; set; } + public DateTime SaleTime { get; set; } + public int Cost { get; set; } + public int ClientId { get; set; } + public int EmployeeId { get; set; } + public List CarIds { get; set; } = new(); + public List ServiseIds { get; set; } = new(); + public SaleDto(ISale model) + { + Id = model.Id; + SaleTime = model.SaleTime; + Cost = model.Cost; + ClientId = model.ClientId; + EmployeeId = model.EmployeeId; + CarIds = model.CarIds; + ServiseIds = model.ServiseIds; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/CarView.cs b/CarShowroom/CarShowroomDataModels/Views/CarView.cs new file mode 100644 index 0000000..79024e2 --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/CarView.cs @@ -0,0 +1,32 @@ +using CarShowroomContracts.AbstractModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class CarView : ICar + { + [DisplayName("Номер машины")] + public int Id { get; set; } + [DisplayName("Цвет")] + public string Color { get; set; } + [DisplayName("Дата производства")] + public DateTime RealiseDate { get; set; } + public int ModelId { get; set; } + [DisplayName("Модель")] + public string ModelName { get; set; } = string.Empty; + [DisplayName("Марка")] + public string MakeName { get; set; } = string.Empty; + public CarView(ICar model) + { + Id = model.Id; + Color = model.Color; + RealiseDate = model.RealiseDate; + ModelId = model.ModelId; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/ClientView.cs b/CarShowroom/CarShowroomDataModels/Views/ClientView.cs new file mode 100644 index 0000000..b0738aa --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/ClientView.cs @@ -0,0 +1,28 @@ +using CarShowroomDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class ClientView : IClient + { + public int Id { get; set; } + [DisplayName("ФИО")] + public string Name { get; set; } + [DisplayName("Email")] + public string Email { get; set; } + [DisplayName("Пароль")] + public string Password { get; set; } + public ClientView(IClient model) + { + Id = model.Id; + Name = model.Name; + Email = model.Email; + Password = model.Password; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs b/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs new file mode 100644 index 0000000..5431043 --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/EmployeeView.cs @@ -0,0 +1,28 @@ +using CarShowroomDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class EmployeeView : IEmployee + { + public int Id { get; set; } + [DisplayName("ФИО")] + public string Name { get; set; } + [DisplayName("Email")] + public string Email { get; set; } + [DisplayName("Пароль")] + public string Password { get; set; } + public EmployeeView(IEmployee model) + { + Id = model.Id; + Name = model.Name; + Email = model.Email; + Password = model.Password; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/MakeView.cs b/CarShowroom/CarShowroomDataModels/Views/MakeView.cs new file mode 100644 index 0000000..6873fe0 --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/MakeView.cs @@ -0,0 +1,22 @@ +using CarShowroomContracts.AbstractModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class MakeView : IMake + { + public int Id { get; set; } + [DisplayName("Название марки")] + public string Name { get; set; } + public MakeView(IMake model) + { + Id = model.Id; + Name = model.Name; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/ModelView.cs b/CarShowroom/CarShowroomDataModels/Views/ModelView.cs new file mode 100644 index 0000000..32c85ef --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/ModelView.cs @@ -0,0 +1,29 @@ +using CarShowroomContracts.AbstractModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class ModelView : IModel + { + public int Id { get; set; } + [DisplayName("Модель")] + public string Name { get; set; } + [DisplayName("Цена")] + public int Price { get; set; } + public int MakeId { get; set; } + [DisplayName("Марка")] + public string MakeName { get; set; } = string.Empty; + public ModelView(IModel model) + { + Id = model.Id; + Name = model.Name; + Price = model.Price; + MakeId = model.MakeId; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/SaleView.cs b/CarShowroom/CarShowroomDataModels/Views/SaleView.cs new file mode 100644 index 0000000..b08c9f1 --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/SaleView.cs @@ -0,0 +1,41 @@ +using CarShowroomContracts.AbstractModels; +using CarShowroomContracts.Dtos; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomDataModels.Dtos +{ + internal class SaleView : ISale + { + [DisplayName("Номер продажи")] + public int Id { get; set; } + [DisplayName("Время")] + public DateTime SaleTime { get; set; } + [DisplayName("Сумма")] + public int Cost { get; set; } + public int ClientId { get; set; } + [DisplayName("Клиент")] + public string ClientName { get; set; } = string.Empty; + public int EmployeeId { get; set; } + [DisplayName("Сотрудник")] + public string EmployeeName { get; set; } = string.Empty; + public List CarIds { get; set; } = new(); + public List Cars { get; set; } = new(); + public List ServiseIds { get; set; } = new(); + public List Servises { get; set; } = new(); + public SaleView(ISale model) + { + Id = model.Id; + SaleTime = model.SaleTime; + Cost = model.Cost; + ClientId = model.ClientId; + EmployeeId = model.EmployeeId; + CarIds = model.CarIds; + ServiseIds = model.ServiseIds; + } + } +} diff --git a/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs new file mode 100644 index 0000000..dafcf1b --- /dev/null +++ b/CarShowroom/CarShowroomDataModels/Views/ServiceView.cs @@ -0,0 +1,22 @@ +using CarShowroomContracts.AbstractModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarShowroomContracts.Dtos +{ + public class ServiceView : IService + { + public int Id { get; set; } + public string Name { get; set; } + public int Cost { get; set; } + public ServiceView(IService model) + { + Id = model.Id; + Name = model.Name; + Cost = model.Cost; + } + } +}