From c0b83e1d878d8423babd0effcae81c14ab037761 Mon Sep 17 00:00:00 2001 From: aleksandr chegodaev Date: Mon, 29 Apr 2024 22:03:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BB=D0=BE=D0=B2=D0=B8=20=D0=BB=D0=B8=D0=BC?= =?UTF-8?q?=D0=BE=D0=BD=D0=BA=D1=83=20=D0=B0=D1=85=D0=B8=20=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/AccountBindingModel.cs | 15 ++++++++ .../BindingModels/CarBindingModel.cs | 21 +++++++++++ .../BindingModels/ImplementerBindingModel.cs | 14 +++++++ .../BusinessLogicContracts/IAccountLogic.cs | 18 +++++++++ .../BusinessLogicContracts/ICarLogic.cs | 16 ++++++++ .../IImplementerLogic.cs | 12 ++++++ .../SearchModels/AccountSearchModel.cs | 13 +++++++ .../SearchModels/CarSearchModel.cs | 13 +++++++ .../SearchModels/ImplementerSearchModel.cs | 9 +++++ .../StoragesContracts/IAccountStorage.cs | 14 +++++++ .../StoragesContracts/ICarStorage.cs | 18 +++++++++ .../StoragesContracts/IImplementerStorage.cs | 12 ++++++ .../ViewModels/AccountViewModel.cs | 21 +++++++++++ CarCenterContracts/ViewModels/CarViewModel.cs | 37 +++++++++++++++++++ .../ViewModels/ImplementerViewModel.cs | 16 ++++++++ 15 files changed, 249 insertions(+) create mode 100644 CarCenterContracts/BindingModels/AccountBindingModel.cs create mode 100644 CarCenterContracts/BindingModels/CarBindingModel.cs create mode 100644 CarCenterContracts/BindingModels/ImplementerBindingModel.cs create mode 100644 CarCenterContracts/BusinessLogicContracts/IAccountLogic.cs create mode 100644 CarCenterContracts/BusinessLogicContracts/ICarLogic.cs create mode 100644 CarCenterContracts/BusinessLogicContracts/IImplementerLogic.cs create mode 100644 CarCenterContracts/SearchModels/AccountSearchModel.cs create mode 100644 CarCenterContracts/SearchModels/CarSearchModel.cs create mode 100644 CarCenterContracts/SearchModels/ImplementerSearchModel.cs create mode 100644 CarCenterContracts/StoragesContracts/IAccountStorage.cs create mode 100644 CarCenterContracts/StoragesContracts/ICarStorage.cs create mode 100644 CarCenterContracts/StoragesContracts/IImplementerStorage.cs create mode 100644 CarCenterContracts/ViewModels/AccountViewModel.cs create mode 100644 CarCenterContracts/ViewModels/CarViewModel.cs create mode 100644 CarCenterContracts/ViewModels/ImplementerViewModel.cs diff --git a/CarCenterContracts/BindingModels/AccountBindingModel.cs b/CarCenterContracts/BindingModels/AccountBindingModel.cs new file mode 100644 index 0000000..87ec927 --- /dev/null +++ b/CarCenterContracts/BindingModels/AccountBindingModel.cs @@ -0,0 +1,15 @@ +using CarCenterDataModels; + +namespace CarCenterContracts.BindingModels +{ + public class AccountBindingModel : IAccountModel + { + public int ClientByCarId { get; set; } + + public DateOnly DateOfAccount { get; set; } = DateOnly.FromDateTime(DateTime.Now); + + public double Price { get; set; } + + public int Id { get; set; } + } +} diff --git a/CarCenterContracts/BindingModels/CarBindingModel.cs b/CarCenterContracts/BindingModels/CarBindingModel.cs new file mode 100644 index 0000000..cd3d96a --- /dev/null +++ b/CarCenterContracts/BindingModels/CarBindingModel.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; +using CarCenterDataModels; +using CarCenterDataModels.ProxyModels; + +namespace CarCenterContracts.BindingModels +{ + public class CarBindingModel : ICarModel + { + public int ImplementerId { get; set; } + public string Name { get; set; } = string.Empty; + public double Price { get; set; } + + public DateOnly DateOfReceipt { get; set; } = DateOnly.FromDateTime(DateTime.Now); + public DateOnly DateOfPassage { get; set; } = DateOnly.FromDateTime(DateTime.Now); + + public Dictionary ClientsModel { get; set; } = new(); + public List RequirementsModel { get; set; } = new(); + + public int Id { get; set; } + } +} diff --git a/CarCenterContracts/BindingModels/ImplementerBindingModel.cs b/CarCenterContracts/BindingModels/ImplementerBindingModel.cs new file mode 100644 index 0000000..55da070 --- /dev/null +++ b/CarCenterContracts/BindingModels/ImplementerBindingModel.cs @@ -0,0 +1,14 @@ +using CarCenterDataModels; + +namespace CarCenterContracts.BindingModels +{ + public class ImplementerBindingModel : IImplementerModel + { + public int Id { get; set; } + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string Login { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string PhoneNumber { get; set; } = string.Empty; + } +} diff --git a/CarCenterContracts/BusinessLogicContracts/IAccountLogic.cs b/CarCenterContracts/BusinessLogicContracts/IAccountLogic.cs new file mode 100644 index 0000000..5efb9a3 --- /dev/null +++ b/CarCenterContracts/BusinessLogicContracts/IAccountLogic.cs @@ -0,0 +1,18 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + +namespace CarCenterContracts.BusinessLogicContracts +{ + public interface IAccountLogic + { + List ReadList(AccountSearchModel model); + AccountViewModel ReadElement(AccountSearchModel model); + bool Create(AccountBindingModel model); + + /// + /// Получение полной и оплаченной стоимости в бизнес логике, по клиенту и дисциплине + /// + bool GetAccountInfo(AccountSearchModel model, out double fullPrice, out double paidPrice); + } +} diff --git a/CarCenterContracts/BusinessLogicContracts/ICarLogic.cs b/CarCenterContracts/BusinessLogicContracts/ICarLogic.cs new file mode 100644 index 0000000..3b060b0 --- /dev/null +++ b/CarCenterContracts/BusinessLogicContracts/ICarLogic.cs @@ -0,0 +1,16 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + + +namespace CarCenterContracts.BusinessLogicContracts +{ + public interface ICarLogic + { + List ReadList(CarSearchModel? model = null); + CarViewModel ReadElement(CarSearchModel model); + bool Create(CarBindingModel model); + bool Update(CarBindingModel model); + bool Delete(CarBindingModel model); + } +} diff --git a/CarCenterContracts/BusinessLogicContracts/IImplementerLogic.cs b/CarCenterContracts/BusinessLogicContracts/IImplementerLogic.cs new file mode 100644 index 0000000..c5cd2de --- /dev/null +++ b/CarCenterContracts/BusinessLogicContracts/IImplementerLogic.cs @@ -0,0 +1,12 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + +namespace CarCenterContracts.BusinessLogicContracts +{ + public interface IImplementerLogic + { + ImplementerViewModel ReadElement(ImplementerSearchModel model); + bool Create(ImplementerBindingModel model); + } +} diff --git a/CarCenterContracts/SearchModels/AccountSearchModel.cs b/CarCenterContracts/SearchModels/AccountSearchModel.cs new file mode 100644 index 0000000..f1d1251 --- /dev/null +++ b/CarCenterContracts/SearchModels/AccountSearchModel.cs @@ -0,0 +1,13 @@ +namespace CarCenterContracts.SearchModels +{ + public class AccountSearchModel + { + public int? Id { get; set; } + + public int? ClientId { get; set; } + public int? CarId { get; set; } + + public DateOnly? DateFrom { get; set; } + public DateOnly? DateTo { get; set; } + } +} diff --git a/CarCenterContracts/SearchModels/CarSearchModel.cs b/CarCenterContracts/SearchModels/CarSearchModel.cs new file mode 100644 index 0000000..d26994c --- /dev/null +++ b/CarCenterContracts/SearchModels/CarSearchModel.cs @@ -0,0 +1,13 @@ +namespace CarCenterContracts.SearchModels +{ + public class CarSearchModel + { + public int? Id { get; set; } + public DateOnly? DateFrom { get; set; } + public DateOnly? DateTo { get; set; } + + public List? ClientsIds { get; set; } + + public int? ImplementerId { get; set; } + } +} diff --git a/CarCenterContracts/SearchModels/ImplementerSearchModel.cs b/CarCenterContracts/SearchModels/ImplementerSearchModel.cs new file mode 100644 index 0000000..7cc9629 --- /dev/null +++ b/CarCenterContracts/SearchModels/ImplementerSearchModel.cs @@ -0,0 +1,9 @@ +namespace CarCenterContracts.SearchModels +{ + public class ImplementerSearchModel + { + public int? Id { get; set; } + public string? Login { get; set; } + public string? Password { get; set; } + } +} diff --git a/CarCenterContracts/StoragesContracts/IAccountStorage.cs b/CarCenterContracts/StoragesContracts/IAccountStorage.cs new file mode 100644 index 0000000..443877c --- /dev/null +++ b/CarCenterContracts/StoragesContracts/IAccountStorage.cs @@ -0,0 +1,14 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + +namespace CarCenterContracts.StoragesContracts +{ + public interface IAccountStorage + { + List GetFullList(); + List GetFilteredList(AccountSearchModel model); + AccountViewModel? GetElement(AccountSearchModel model); + AccountViewModel? Insert(AccountBindingModel model); + } +} diff --git a/CarCenterContracts/StoragesContracts/ICarStorage.cs b/CarCenterContracts/StoragesContracts/ICarStorage.cs new file mode 100644 index 0000000..a31a5d9 --- /dev/null +++ b/CarCenterContracts/StoragesContracts/ICarStorage.cs @@ -0,0 +1,18 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + +namespace CarCenterContracts.StoragesContracts +{ + public interface ICarStorage + { + List GetFullList(); + List GetFilteredList(CarSearchModel model); + CarViewModel? GetElement(CarSearchModel model); + CarViewModel? Insert(CarBindingModel model); + CarViewModel? Update(CarBindingModel model); + CarViewModel? Delete(CarBindingModel model); + + List GetAccountsFromCarAndClient(CarSearchModel modelCar, ClientSearchModel modelClient); + } +} diff --git a/CarCenterContracts/StoragesContracts/IImplementerStorage.cs b/CarCenterContracts/StoragesContracts/IImplementerStorage.cs new file mode 100644 index 0000000..b10a74c --- /dev/null +++ b/CarCenterContracts/StoragesContracts/IImplementerStorage.cs @@ -0,0 +1,12 @@ +using CarCenterContracts.BindingModels; +using CarCenterContracts.SearchModels; +using CarCenterContracts.ViewModels; + +namespace CarCenterContracts.StoragesContracts +{ + public interface IImplementerStorage + { + ImplementerViewModel? GetElement(ImplementerSearchModel model); + ImplementerViewModel? Insert(ImplementerBindingModel model); + } +} diff --git a/CarCenterContracts/ViewModels/AccountViewModel.cs b/CarCenterContracts/ViewModels/AccountViewModel.cs new file mode 100644 index 0000000..55082cc --- /dev/null +++ b/CarCenterContracts/ViewModels/AccountViewModel.cs @@ -0,0 +1,21 @@ +using CarCenterDataModels; +using System.ComponentModel; +using CarCenterDataModels.ProxyModels; + +namespace CarCenterContracts.ViewModels +{ + public class AccountViewModel : IAccountModel + { + public int Id { get; set; } + public int ClientByCarId { get; set; } + public DateOnly DateOfAccount { get; set; } = DateOnly.FromDateTime(DateTime.Now); + + public double Price { get; set; } + + public ClientByCarModel ClientByCar { get; set; } + + public ClientViewModel? Client { get; set; } + + public CarViewModel? Car { get; set; } + } +} diff --git a/CarCenterContracts/ViewModels/CarViewModel.cs b/CarCenterContracts/ViewModels/CarViewModel.cs new file mode 100644 index 0000000..fff2afd --- /dev/null +++ b/CarCenterContracts/ViewModels/CarViewModel.cs @@ -0,0 +1,37 @@ +using CarCenterDataModels; +using System.ComponentModel; +using System.Text; +using CarCenterDataModels.ProxyModels; + +namespace CarCenterContracts.ViewModels +{ + public class CarViewModel : ICarModel + { + public int Id { get; set; } + public int ImplementerId { get; set; } + public string Name { get; set; } = string.Empty; + public double Price { get; set; } + + [DisplayName("Логин клиента")] + public string DirectorLogin { get; set; } = string.Empty; + + public Dictionary ClientsModel { get; set; } = new(); + public List RequirementViewModels { get; set; } = new(); + + public List ClientViewModels { get; set; } = new(); + + public override string ToString() + { + var result = new StringBuilder( + $"Автомобиль {Name} " + + $"был куплен клиентом:"); + for (int i = 0; i < ClientViewModels.Count; i++) + { + var Car = ClientViewModels[i]; + result.Append($"\n\t{i + 1}. {Car.Name} на " + + $"{ClientsModel[Car.Id].DateOfClient.ToShortDateString()}"); + } + return result.ToString(); + } + } +} diff --git a/CarCenterContracts/ViewModels/ImplementerViewModel.cs b/CarCenterContracts/ViewModels/ImplementerViewModel.cs new file mode 100644 index 0000000..43b507a --- /dev/null +++ b/CarCenterContracts/ViewModels/ImplementerViewModel.cs @@ -0,0 +1,16 @@ +using CarCenterDataModels; +using System.ComponentModel; + +namespace CarCenterContracts.ViewModels +{ + public class ImplementerViewModel : IImplementerModel + { + public int Id { get; set; } + public string LastName { get; set; } = string.Empty; + public string FirstName { get; set; } = string.Empty; + public string Login { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + + public string PhoneNumber { get; set; } = string.Empty; + } +}