лови лимонку ахи брат

This commit is contained in:
aleksandr chegodaev 2024-04-29 22:03:01 +04:00
parent fbddedb5e9
commit c0b83e1d87
15 changed files with 249 additions and 0 deletions

View File

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

View File

@ -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<int, ClientByCarModel> ClientsModel { get; set; } = new();
public List<RequirementByCarModel> RequirementsModel { get; set; } = new();
public int Id { get; set; }
}
}

View File

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

View File

@ -0,0 +1,18 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.SearchModels;
using CarCenterContracts.ViewModels;
namespace CarCenterContracts.BusinessLogicContracts
{
public interface IAccountLogic
{
List<AccountViewModel> ReadList(AccountSearchModel model);
AccountViewModel ReadElement(AccountSearchModel model);
bool Create(AccountBindingModel model);
/// <summary>
/// Получение полной и оплаченной стоимости в бизнес логике, по клиенту и дисциплине
/// </summary>
bool GetAccountInfo(AccountSearchModel model, out double fullPrice, out double paidPrice);
}
}

View File

@ -0,0 +1,16 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.SearchModels;
using CarCenterContracts.ViewModels;
namespace CarCenterContracts.BusinessLogicContracts
{
public interface ICarLogic
{
List<CarViewModel> ReadList(CarSearchModel? model = null);
CarViewModel ReadElement(CarSearchModel model);
bool Create(CarBindingModel model);
bool Update(CarBindingModel model);
bool Delete(CarBindingModel model);
}
}

View File

@ -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);
}
}

View File

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

View File

@ -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<int>? ClientsIds { get; set; }
public int? ImplementerId { get; set; }
}
}

View File

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

View File

@ -0,0 +1,14 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.SearchModels;
using CarCenterContracts.ViewModels;
namespace CarCenterContracts.StoragesContracts
{
public interface IAccountStorage
{
List<AccountViewModel> GetFullList();
List<AccountViewModel> GetFilteredList(AccountSearchModel model);
AccountViewModel? GetElement(AccountSearchModel model);
AccountViewModel? Insert(AccountBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using CarCenterContracts.BindingModels;
using CarCenterContracts.SearchModels;
using CarCenterContracts.ViewModels;
namespace CarCenterContracts.StoragesContracts
{
public interface ICarStorage
{
List<CarViewModel> GetFullList();
List<CarViewModel> GetFilteredList(CarSearchModel model);
CarViewModel? GetElement(CarSearchModel model);
CarViewModel? Insert(CarBindingModel model);
CarViewModel? Update(CarBindingModel model);
CarViewModel? Delete(CarBindingModel model);
List<AccountViewModel> GetAccountsFromCarAndClient(CarSearchModel modelCar, ClientSearchModel modelClient);
}
}

View File

@ -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);
}
}

View File

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

View File

@ -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<int, ClientByCarModel> ClientsModel { get; set; } = new();
public List<RequirementViewModel> RequirementViewModels { get; set; } = new();
public List<ClientViewModel> 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();
}
}
}

View File

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