Слой контрактов

This commit is contained in:
Вячеслав Иванов 2024-02-25 12:18:35 +04:00
parent ab011997b0
commit a0251dbb00
31 changed files with 400 additions and 5 deletions

View File

@ -0,0 +1,11 @@
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class CargoBindingModel : ICargoModel
{
public int Id { get; set; }
public string CargoName { get; set; } = string.Empty;
public int Weight { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class DriverBindingModel : IDriverModel
{
public int Id { get; set; }
public string DriverFio { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,11 @@
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class PointBindingModel : IPointModel
{
public int Id { get; set; }
public string PointName { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,12 @@
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class TransportBindingModel : ITransportModel
{
public int Id { get; set; }
public string Model { get; set; } = string.Empty;
public int LoadCapacity { get; set; }
public string StateNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using TransportCompanyDataModels.Enums;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.BindingModels
{
public class TransportationBindingModel : ITransportationModel
{
public int Id { get; set; }
public int DriverId { get; set; }
public int TransportId { get; set; }
public int PointToId { get; set; }
public int PointFromId { get; set; }
public TransportationStatus Status { get; set; } = TransportationStatus.Неизвестен;
public DateTime DepartureDate { get; set; } = DateTime.Now;
public DateTime? ArrivalDate { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ICargoLogic
{
List<CargoViewModel>? ReadList(CargoSearchModel? model);
CargoViewModel? ReadElement(CargoSearchModel model);
bool Create(CargoBindingModel model);
bool Update(CargoBindingModel model);
bool Delete(CargoBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface IDriverLogic
{
List<DriverViewModel>? ReadList(DriverSearchModel? model);
DriverViewModel? ReadElement(DriverSearchModel model);
bool Create(DriverBindingModel model);
bool Update(DriverBindingModel model);
bool Delete(DriverBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface IPointLogic
{
List<PointViewModel>? ReadList(PointSearchModel? model);
PointViewModel? ReadElement(PointSearchModel model);
bool Create(PointBindingModel model);
bool Update(PointBindingModel model);
bool Delete(PointBindingModel model);
}
}

View File

@ -0,0 +1,15 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ITransportLogic
{
List<TransportViewModel>? ReadList(TransportSearchModel? model);
TransportViewModel? ReadElement(TransportSearchModel model);
bool Create(TransportBindingModel model);
bool Update(TransportBindingModel model);
bool Delete(TransportBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.BusinessLogicsContracts
{
public interface ITransportationLogic
{
List<TransportationViewModel>? ReadList(TransportationSearchModel? searchModel);
bool CreateTransportation(TransportationBindingModel bindingModel);
bool DeliveredTransportation(TransportationBindingModel bindingModel);
bool ArrivedTransportation(TransportationBindingModel bindingModel);
bool IssueTransportation(TransportationBindingModel bindingModel);
}
}

View File

@ -0,0 +1,8 @@
namespace TransportCompanyContracts.SearchModels
{
public class CargoSearchModel
{
public int? Id { get; set; }
public string? CargoName { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace TransportCompanyContracts.SearchModels
{
public class DriverSearchModel
{
public int? Id { get; set; }
public string? DriverFio { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace TransportCompanyContracts.SearchModels
{
public class PointSearchModel
{
public int? Id { get; set; }
public string? PointName { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace TransportCompanyContracts.SearchModels
{
public class TransportSearchModel
{
public int? Id { get; set; }
public string? Model { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace TransportCompanyContracts.SearchModels
{
public class TransportationSearchModel
{
public int? Id { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ICargoStorage
{
List<CargoViewModel> GetFullList();
List<CargoViewModel> GetFilteredList(CargoSearchModel model);
CargoViewModel? GetElement(CargoSearchModel model);
CargoViewModel? Insert(CargoBindingModel model);
CargoViewModel? Update(CargoBindingModel model);
CargoViewModel? Delete(CargoBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface IDriverStorage
{
List<DriverViewModel> GetFullList();
List<DriverViewModel> GetFilteredList(DriverSearchModel model);
DriverViewModel? GetElement(DriverSearchModel model);
DriverViewModel? Insert(DriverBindingModel model);
DriverViewModel? Update(DriverBindingModel model);
DriverViewModel? Delete(DriverBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface IPointStorage
{
List<PointViewModel> GetFullList();
List<PointViewModel> GetFilteredList(PointSearchModel model);
PointViewModel? GetElement(PointSearchModel model);
PointViewModel? Insert(PointBindingModel model);
PointViewModel? Update(PointBindingModel model);
PointViewModel? Delete(PointBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ITransportStorage
{
List<TransportViewModel> GetFullList();
List<TransportViewModel> GetFilteredList(TransportSearchModel model);
TransportViewModel? GetElement(TransportSearchModel model);
TransportViewModel? Insert(TransportBindingModel model);
TransportViewModel? Update(TransportBindingModel model);
TransportViewModel? Delete(TransportBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using TransportCompanyContracts.BindingModels;
using TransportCompanyContracts.SearchModels;
using TransportCompanyContracts.ViewModels;
namespace TransportCompanyContracts.StoragesContracts
{
public interface ITransportationStorage
{
List<TransportationViewModel> GetFullList();
List<TransportationViewModel> GetFilteredList(TransportationSearchModel model);
TransportationViewModel? GetElement(TransportationSearchModel model);
TransportationViewModel? Insert(TransportationBindingModel model);
TransportationViewModel? Update(TransportationBindingModel model);
TransportationViewModel? Delete(TransportationBindingModel model);
}
}

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,16 @@
using System.ComponentModel;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class CargoViewModel : ICargoModel
{
public int Id { get; set; }
[DisplayName("Груз")]
public string CargoName { get; set; } = string.Empty;
[DisplayName("Вес")]
public int Weight { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class DriverViewModel : IDriverModel
{
public int Id { get; set; }
[DisplayName("ФИО водителя")]
public string DriverFio { get; set; } = string.Empty;
[DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,16 @@
using System.ComponentModel;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class PointViewModel : IPointModel
{
public int Id { get; set; }
[DisplayName("Пункт")]
public string PointName { get; set; } = string.Empty;
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,19 @@
using System.ComponentModel;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class TransportViewModel : ITransportModel
{
public int Id { get; set; }
[DisplayName("Модель")]
public string Model { get; set; } = string.Empty;
[DisplayName("Вместимость")]
public int LoadCapacity { get; set; }
[DisplayName("Автомобильный номер")]
public string StateNumber { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,41 @@
using System.ComponentModel;
using TransportCompanyDataModels.Enums;
using TransportCompanyDataModels.Models;
namespace TransportCompanyContracts.ViewModels
{
public class TransportationViewModel : ITransportationModel
{
[DisplayName("Номер")]
public int Id { get; set; }
public int DriverId { get; set; }
[DisplayName("Водитель")]
public string DriverFio { get; set; } = string.Empty;
public int TransportId { get; set; }
[DisplayName("Машина")]
public string Model { get; set; } = string.Empty;
public int PointToId { get; set; }
[DisplayName("Откуда")]
public string PointNameTo { get; set; } = string.Empty;
public int PointFromId { get; set; }
[DisplayName("Куда")]
public string PointNameFrom { get; set; } = string.Empty;
[DisplayName("Статус")]
public TransportationStatus Status { get; set; } = TransportationStatus.Неизвестен;
[DisplayName("Дата отбытия")]
public DateTime DepartureDate { get; set; } = DateTime.Now;
[DisplayName("Дата прибытия")]
public DateTime? ArrivalDate { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace TransportCompanyDataModels.Enums
{
public enum TransportationStatus
{
Неизвестен = -1,
Принят = 0,
Доставляется = 1,
Прибыл = 2,
Выдан = 3
}
}

View File

@ -2,7 +2,7 @@
{ {
public interface ICargoModel : IId public interface ICargoModel : IId
{ {
string Name { get; } string CargoName { get; }
int Weight { get; } int Weight { get; }
} }
} }

View File

@ -2,6 +2,7 @@
{ {
public interface IDriverModel : IId public interface IDriverModel : IId
{ {
string Fio { get; } string DriverFio { get; }
string PhoneNumber { get; }
} }
} }

View File

@ -2,7 +2,7 @@
{ {
public interface IPointModel : IId public interface IPointModel : IId
{ {
string Name { get; } string PointName { get; }
string Address { get; } string Address { get; }
} }
} }

View File

@ -1,4 +1,6 @@
namespace TransportCompanyDataModels.Models using TransportCompanyDataModels.Enums;
namespace TransportCompanyDataModels.Models
{ {
public interface ITransportationModel : IId public interface ITransportationModel : IId
{ {
@ -6,7 +8,8 @@
int TransportId { get; } int TransportId { get; }
int PointToId { get; } int PointToId { get; }
int PointFromId { get; } int PointFromId { get; }
TransportationStatus Status { get; }
DateTime DepartureDate { get; } DateTime DepartureDate { get; }
DateTime ArrivalDate { get; } DateTime? ArrivalDate { get; }
} }
} }