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; + } +}