add domain entities

This commit is contained in:
cuqmbr 2023-11-02 07:56:12 +02:00
parent b08ae03fbe
commit 58140b6f70
Signed by: cuqmbr
GPG Key ID: 2D72ED98B6CB200F
30 changed files with 443 additions and 0 deletions

View File

@ -0,0 +1,8 @@
namespace AutobusApi.Domain.Common;
public class EntityBase
{
public required int Id { get; set; }
public required bool IsDeleted { get; set; }
}

View File

@ -0,0 +1,20 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
using AutobusApi.Domain.IEntities;
namespace AutobusApi.Domain.Entities;
public class Address : EntityBase
{
public required string Name { get; set; }
public required ICoordinates Location { get; set; }
public required VehicleType VehicleType { get; set; }
public ICollection<RouteAddress> RouteAddresses { get; set; } = null!;
public required int CityId { get; set; }
public City City { get; set; } = null!;
}

View File

@ -0,0 +1,16 @@
namespace AutobusApi.Domain.Entities;
public class Aircraft : Vehicle
{
public Vehicle Vehicle { get; set; } = null!;
public required string Number { get; set; }
public required string Model { get; set; }
public required int Capacity { get; set; }
public required bool HasWiFi { get; set; }
public required bool HasMultimedia { get; set; }
}

View File

@ -0,0 +1,22 @@
namespace AutobusApi.Domain.Entities;
public class Bus : Vehicle
{
public Vehicle Vehicle { get; set; } = null!;
public required string Number { get; set; }
public required string Model { get; set; }
public required int Capacity { get; set; }
public required bool HasClimateControl { get; set; }
public required bool HasWC { get; set; }
public required bool HasWiFi { get; set; }
public required bool HasMultimedia { get; set; }
public required bool HasOutlets { get; set; }
}

View File

@ -0,0 +1,19 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
namespace AutobusApi.Domain.Entities;
public class Carriage : EntityBase
{
public required CarriageType Type { get; set; }
public required int Capacity { get; set; }
public required int Number { get; set; }
public required bool HasWiFi { get; set; }
public required bool HasOutlets { get; set; }
public ICollection<TrainCarriage> TrainCarriage { get; set; } = null!;
}

View File

@ -0,0 +1,14 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class City : EntityBase
{
public required string Name { get; set; }
public ICollection<Address> Addresses { get; set; } = null!;
public required int RegionId { get; set; }
public Region Region { get; set; } = null!;
}

View File

@ -0,0 +1,18 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Company : EntityBase
{
public required string Name { get; set; }
public required string LegalAddress { get; set; }
public required string ContactEmail { get; set; }
public required string ContactPhoneNumber { get; set; }
public ICollection<Vehicle> Vehicles { get; set; } = null!;
public ICollection<Employee> Employees { get; set; } = null!;
}

View File

@ -0,0 +1,10 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Country : EntityBase
{
public required string Name { get; set; }
public ICollection<Region> Regions { get; set; } = null!;
}

View File

@ -0,0 +1,25 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
namespace AutobusApi.Domain.Entities;
public class Employee : EntityBase
{
public required string FisrtName { get; set; }
public required string LastName { get; set; }
public required string Patronymic { get; set; }
public required Sex Sex { get; set; }
public required DateOnly BirthDate { get; set; }
public required int EmployerCompanyId { get; set; }
public Company EmployerCompany { get; set; } = null!;
public ICollection<EmployeeDocument> Documents { get; set; } = null!;
public ICollection<VehicleEnrollmentEmployee> Shifts { get; set; } = null!;
}

View File

@ -0,0 +1,15 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
namespace AutobusApi.Domain.Entities;
public class EmployeeDocument : EntityBase
{
public required EmployeeDocumentType Type { get; set; }
public required string Information { get; set; }
public required int EmployeeId { get; set; }
public Employee Employee { get; set; } = null!;
}

View File

@ -0,0 +1,14 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Region : EntityBase
{
public required string Name { get; set; }
public ICollection<City> Cities { get; set; } = null!;
public required int CountryId { get; set; }
public Country Country { get; set; } = null!;
}

View File

@ -0,0 +1,20 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Review : EntityBase
{
public required int Rating { get; set; }
public required string? Comment { get; set; }
public required DateTime PostDateTimeUtc { get; set; }
public required int UserId { get; set; }
public User User { get; set; } = null!;
public required int VehicleEnrollmentId { get; set; }
public VehicleEnrollment VehicleEnrollment { get; set; } = null!;
}

View File

@ -0,0 +1,10 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Route : EntityBase
{
public ICollection<RouteAddress> RouteAddresses { get; set; } = null!;
public ICollection<VehicleEnrollment> VehicleEnrollments { get; set; } = null!;
}

View File

@ -0,0 +1,18 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class RouteAddress : EntityBase
{
public required int Order { get; set; }
public required int AddressId { get; set; }
public Address Address { get; set; } = null!;
public required int RouteId { get; set; }
public Route Route { get; set; } = null!;
public ICollection<RouteAddressDetails> RouteAddressDetails { get; set; } = null!;
}

View File

@ -0,0 +1,20 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class RouteAddressDetails : EntityBase
{
public required TimeSpan TimeToNextAddress { get; set; }
public required double CostToNextAddress { get; set; }
public required TimeSpan CurrentAddressStopTime { get; set; }
public required int RouteAddressId { get; set; }
public RouteAddress RouteAddress { get; set; } = null!;
public required int VehicleEnrollmentId { get; set; }
public VehicleEnrollment VehicleEnrollment { get; set; } = null!;
}

View File

@ -0,0 +1,14 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Ticket : EntityBase
{
public required int TicketGroupId { get; set; }
public TicketGroup TicketGroup { get; set; } = null!;
public required int VehicleEnrollmentId { get; set; }
public VehicleEnrollment VehicleEnrollment { get; set; } = null!;
}

View File

@ -0,0 +1,15 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
namespace AutobusApi.Domain.Entities;
public class TicketDocument : EntityBase
{
public required TicketDocumentType Type { get; set; }
public required string Information { get; set; }
public required int TicketGroupId { get; set; }
public TicketGroup TicketGroup { get; set; } = null!;
}

View File

@ -0,0 +1,39 @@
using AutobusApi.Domain.Common;
using AutobusApi.Domain.Enums;
namespace AutobusApi.Domain.Entities;
public class TicketGroup : EntityBase
{
public required string BuyerFirstName { get; set; }
public required string BuyerLastName { get; set; }
public required string BuyerPhoneNumber { get; set; }
public required string BuyerEmailAddress { get; set; }
public required string PassengerFirstName { get; set; }
public required string PassengerLastName { get; set; }
public required string PassengerPatronymic { get; set; }
public required Sex PassengerSex { get; set; }
public required DateOnly PassengerBirthDate { get; set; }
public required DateTime PurchaseDateTimeUtc { get; set; }
public required bool IsReturned { get; set; }
public int? UserId { get; set; }
public User? User { get; set; }
public required int TicketDocumentId { get; set; }
public TicketDocument TicketDocument { get; set; } = null!;
public ICollection<Ticket> Tickets { get; set; } = null!;
}

View File

@ -0,0 +1,10 @@
namespace AutobusApi.Domain.Entities;
public class Train : Vehicle
{
public Vehicle Vehicle { get; set; } = null!;
public required string Number { get; set; }
public ICollection<TrainCarriage> TrainCarriage { get; set; } = null!;
}

View File

@ -0,0 +1,14 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class TrainCarriage : EntityBase
{
public required int TrainId { get; set; }
public Train Train { get; set; } = null!;
public required int CarriageId { get; set; }
public Carriage Carriage { get; set; } = null!;
}

View File

@ -0,0 +1,10 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class User : EntityBase
{
public ICollection<TicketGroup> TicketGroups { get; set; } = null!;
public ICollection<Review> Reviews { get; set; } = null!;
}

View File

@ -0,0 +1,12 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class Vehicle : EntityBase
{
public required int CompanyId { get; set; }
public Company Company { get; set; } = null!;
public ICollection<VehicleEnrollment> Enrollments { get; set; } = null!;
}

View File

@ -0,0 +1,24 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class VehicleEnrollment : EntityBase
{
public required DateTime DepartureDateTimeUtc { get; set; }
public required int VehicleId { get; set; }
public Vehicle Vehicle { get; set; } = null!;
public required int RouteId { get; set; }
public Route Route { get; set; } = null!;
public ICollection<RouteAddressDetails> RouteAddressDetails { get; set; } = null!;
public ICollection<VehicleEnrollmentEmployee> Crew { get; set; } = null!;
public ICollection<Ticket> Tickets { get; set; } = null!;
public ICollection<Review> Reviews { get; set; } = null!;
}

View File

@ -0,0 +1,14 @@
using AutobusApi.Domain.Common;
namespace AutobusApi.Domain.Entities;
public class VehicleEnrollmentEmployee : EntityBase
{
public required int EmployeeId { get; set; }
public Employee Employee { get; set; } = null!;
public required int VehicleEnrollmentId { get; set; }
public VehicleEnrollment VehicleEnrollment { get; set; } = null!;
}

View File

@ -0,0 +1,7 @@
namespace AutobusApi.Domain.Enums;
public enum CarriageType
{
Coupe = 0,
ReservedSeat = 1
}

View File

@ -0,0 +1,6 @@
namespace AutobusApi.Domain.Enums;
public enum EmployeeDocumentType
{
Passport = 0
}

View File

@ -0,0 +1,7 @@
namespace AutobusApi.Domain.Enums;
public enum Sex
{
Male = 0,
Female = 1,
}

View File

@ -0,0 +1,6 @@
namespace AutobusApi.Domain.Enums;
public enum TicketDocumentType
{
Passport = 0
}

View File

@ -0,0 +1,8 @@
namespace AutobusApi.Domain.Enums;
public enum VehicleType
{
Bus = 0,
Train = 1,
Aircraft = 2
}

View File

@ -0,0 +1,8 @@
namespace AutobusApi.Domain.IEntities;
public interface ICoordinates
{
double Latitude { get; }
double Longitude { get; }
}