diff --git a/Server/Data/SeedData.cs b/Server/Data/SeedData.cs index f415e5e..3a0ab8c 100644 --- a/Server/Data/SeedData.cs +++ b/Server/Data/SeedData.cs @@ -281,19 +281,18 @@ public class SeedData new TicketGroup { UserId = companyUser.Id, + PurchaseDateTimeUtc = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 08, 00, 00, DateTimeKind.Utc).AddDays(-1), Tickets = new List { new Ticket { VehicleEnrollmentId = 1, - PurchaseDateTimeUtc = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 08, 00, 00, DateTimeKind.Utc).AddDays(-1), FirstRouteAddressId = 1, LastRouteAddressId = 2 }, new Ticket { VehicleEnrollmentId = 2, - PurchaseDateTimeUtc = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 08, 00, 00, DateTimeKind.Utc).AddDays(-1), FirstRouteAddressId = 2, LastRouteAddressId = 9 } diff --git a/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.Designer.cs b/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.Designer.cs new file mode 100644 index 0000000..d8073ce --- /dev/null +++ b/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.Designer.cs @@ -0,0 +1,958 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Server.Data; + +#nullable disable + +namespace Server.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup")] + partial class Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Server.Models.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CityId") + .HasColumnType("integer"); + + b.Property("Latitude") + .HasColumnType("double precision"); + + b.Property("Longitude") + .HasColumnType("double precision"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CityId"); + + b.ToTable("Addresses"); + }); + + modelBuilder.Entity("Server.Models.City", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("StateId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StateId"); + + b.ToTable("Cities"); + }); + + modelBuilder.Entity("Server.Models.Company", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId") + .IsUnique(); + + b.ToTable("Companies"); + }); + + modelBuilder.Entity("Server.Models.CompanyDriver", b => + { + b.Property("CompanyId") + .HasColumnType("integer"); + + b.Property("DriverId") + .HasColumnType("text"); + + b.HasKey("CompanyId", "DriverId"); + + b.HasIndex("DriverId") + .IsUnique(); + + b.ToTable("CompanyDrivers"); + }); + + modelBuilder.Entity("Server.Models.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Countries"); + }); + + modelBuilder.Entity("Server.Models.Review", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Comment") + .HasColumnType("text"); + + b.Property("PostDateTimeUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("Rating") + .HasColumnType("integer"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.Property("VehicleEnrollmentId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("VehicleEnrollmentId"); + + b.ToTable("Reviews"); + }); + + modelBuilder.Entity("Server.Models.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Routes"); + }); + + modelBuilder.Entity("Server.Models.RouteAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AddressId") + .HasColumnType("integer"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("RouteAddressDetailsId") + .HasColumnType("integer"); + + b.Property("RouteId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AddressId"); + + b.HasIndex("RouteId"); + + b.ToTable("RouteAddresses"); + }); + + modelBuilder.Entity("Server.Models.RouteAddressDetails", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CostToNextCity") + .HasColumnType("double precision"); + + b.Property("RouteAddressId") + .HasColumnType("integer"); + + b.Property("TimeSpanToNextCity") + .HasColumnType("interval"); + + b.Property("VehicleEnrollmentId") + .HasColumnType("integer"); + + b.Property("WaitTimeSpan") + .HasColumnType("interval"); + + b.HasKey("Id"); + + b.HasIndex("RouteAddressId"); + + b.HasIndex("VehicleEnrollmentId"); + + b.ToTable("RouteAddressDetails"); + }); + + modelBuilder.Entity("Server.Models.State", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CountryId") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CountryId"); + + b.ToTable("States"); + }); + + modelBuilder.Entity("Server.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstRouteAddressId") + .HasColumnType("integer"); + + b.Property("LastRouteAddressId") + .HasColumnType("integer"); + + b.Property("TicketGroupId") + .HasColumnType("integer"); + + b.Property("VehicleEnrollmentId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("TicketGroupId"); + + b.HasIndex("VehicleEnrollmentId"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Server.Models.TicketGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsReturned") + .HasColumnType("boolean"); + + b.Property("PurchaseDateTimeUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("TicketGroups"); + }); + + modelBuilder.Entity("Server.Models.User", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("BirthDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Document") + .HasColumnType("integer"); + + b.Property("DocumentDetails") + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Server.Models.Vehicle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property("CompanyId") + .HasColumnType("integer"); + + b.Property("HasBelts") + .HasColumnType("boolean"); + + b.Property("HasClimateControl") + .HasColumnType("boolean"); + + b.Property("HasOutlet") + .HasColumnType("boolean"); + + b.Property("HasStewardess") + .HasColumnType("boolean"); + + b.Property("HasTV") + .HasColumnType("boolean"); + + b.Property("HasWC") + .HasColumnType("boolean"); + + b.Property("HasWiFi") + .HasColumnType("boolean"); + + b.Property("Number") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CompanyId"); + + b.ToTable("Vehicles"); + }); + + modelBuilder.Entity("Server.Models.VehicleEnrollment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CancellationComment") + .HasColumnType("text"); + + b.Property("DelayTimeSpan") + .HasColumnType("interval"); + + b.Property("DepartureDateTimeUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("IsCanceled") + .HasColumnType("boolean"); + + b.Property("RouteId") + .HasColumnType("integer"); + + b.Property("VehicleId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RouteId"); + + b.HasIndex("VehicleId"); + + b.ToTable("VehicleEnrollments"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Server.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Server.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Server.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Server.Models.Address", b => + { + b.HasOne("Server.Models.City", "City") + .WithMany("Addresses") + .HasForeignKey("CityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("City"); + }); + + modelBuilder.Entity("Server.Models.City", b => + { + b.HasOne("Server.Models.State", "State") + .WithMany("Cities") + .HasForeignKey("StateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("State"); + }); + + modelBuilder.Entity("Server.Models.Company", b => + { + b.HasOne("Server.Models.User", "Owner") + .WithOne("Company") + .HasForeignKey("Server.Models.Company", "OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Server.Models.CompanyDriver", b => + { + b.HasOne("Server.Models.Company", "Company") + .WithMany("CompanyDrivers") + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.User", "Driver") + .WithOne("Employer") + .HasForeignKey("Server.Models.CompanyDriver", "DriverId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + + b.Navigation("Driver"); + }); + + modelBuilder.Entity("Server.Models.Review", b => + { + b.HasOne("Server.Models.User", "User") + .WithMany("Reviews") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment") + .WithMany("Reviews") + .HasForeignKey("VehicleEnrollmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + + b.Navigation("VehicleEnrollment"); + }); + + modelBuilder.Entity("Server.Models.RouteAddress", b => + { + b.HasOne("Server.Models.Address", "Address") + .WithMany("RouteAddresses") + .HasForeignKey("AddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.Route", "Route") + .WithMany("RouteAddresses") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Route"); + }); + + modelBuilder.Entity("Server.Models.RouteAddressDetails", b => + { + b.HasOne("Server.Models.RouteAddress", "RouteAddress") + .WithMany("RouteAddressDetails") + .HasForeignKey("RouteAddressId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment") + .WithMany("RouteAddressDetails") + .HasForeignKey("VehicleEnrollmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RouteAddress"); + + b.Navigation("VehicleEnrollment"); + }); + + modelBuilder.Entity("Server.Models.State", b => + { + b.HasOne("Server.Models.Country", "Country") + .WithMany("States") + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("Server.Models.Ticket", b => + { + b.HasOne("Server.Models.TicketGroup", "TicketGroup") + .WithMany("Tickets") + .HasForeignKey("TicketGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment") + .WithMany("Tickets") + .HasForeignKey("VehicleEnrollmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TicketGroup"); + + b.Navigation("VehicleEnrollment"); + }); + + modelBuilder.Entity("Server.Models.TicketGroup", b => + { + b.HasOne("Server.Models.User", "User") + .WithMany("TicketGroups") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Server.Models.User", b => + { + b.OwnsMany("Server.Models.RefreshToken", "RefreshTokens", b1 => + { + b1.Property("UserId") + .HasColumnType("text"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("CreationDateTime") + .HasColumnType("timestamp with time zone"); + + b1.Property("ExpiryDateTime") + .HasColumnType("timestamp with time zone"); + + b1.Property("Revoked") + .HasColumnType("timestamp with time zone"); + + b1.Property("Token") + .IsRequired() + .HasColumnType("text"); + + b1.HasKey("UserId", "Id"); + + b1.ToTable("RefreshToken"); + + b1.WithOwner() + .HasForeignKey("UserId"); + }); + + b.Navigation("RefreshTokens"); + }); + + modelBuilder.Entity("Server.Models.Vehicle", b => + { + b.HasOne("Server.Models.Company", "Company") + .WithMany("Vehicles") + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Company"); + }); + + modelBuilder.Entity("Server.Models.VehicleEnrollment", b => + { + b.HasOne("Server.Models.Route", "Route") + .WithMany("VehicleEnrollments") + .HasForeignKey("RouteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Server.Models.Vehicle", "Vehicle") + .WithMany("VehicleEnrollments") + .HasForeignKey("VehicleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Route"); + + b.Navigation("Vehicle"); + }); + + modelBuilder.Entity("Server.Models.Address", b => + { + b.Navigation("RouteAddresses"); + }); + + modelBuilder.Entity("Server.Models.City", b => + { + b.Navigation("Addresses"); + }); + + modelBuilder.Entity("Server.Models.Company", b => + { + b.Navigation("CompanyDrivers"); + + b.Navigation("Vehicles"); + }); + + modelBuilder.Entity("Server.Models.Country", b => + { + b.Navigation("States"); + }); + + modelBuilder.Entity("Server.Models.Route", b => + { + b.Navigation("RouteAddresses"); + + b.Navigation("VehicleEnrollments"); + }); + + modelBuilder.Entity("Server.Models.RouteAddress", b => + { + b.Navigation("RouteAddressDetails"); + }); + + modelBuilder.Entity("Server.Models.State", b => + { + b.Navigation("Cities"); + }); + + modelBuilder.Entity("Server.Models.TicketGroup", b => + { + b.Navigation("Tickets"); + }); + + modelBuilder.Entity("Server.Models.User", b => + { + b.Navigation("Company") + .IsRequired(); + + b.Navigation("Employer"); + + b.Navigation("Reviews"); + + b.Navigation("TicketGroups"); + }); + + modelBuilder.Entity("Server.Models.Vehicle", b => + { + b.Navigation("VehicleEnrollments"); + }); + + modelBuilder.Entity("Server.Models.VehicleEnrollment", b => + { + b.Navigation("Reviews"); + + b.Navigation("RouteAddressDetails"); + + b.Navigation("Tickets"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.cs b/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.cs new file mode 100644 index 0000000..6ffdb67 --- /dev/null +++ b/Server/Migrations/20230513115729_Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup.cs @@ -0,0 +1,81 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Server.Migrations +{ + public partial class Move_PurchaseDateTime_and_IsReturned_fields_from_Ticket_to_TicketGroup : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsMissed", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "IsReturned", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "PurchaseDateTimeUtc", + table: "Tickets"); + + migrationBuilder.RenameColumn( + name: "CancelationComment", + table: "VehicleEnrollments", + newName: "CancellationComment"); + + migrationBuilder.AddColumn( + name: "IsReturned", + table: "TicketGroups", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "PurchaseDateTimeUtc", + table: "TicketGroups", + type: "timestamp with time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsReturned", + table: "TicketGroups"); + + migrationBuilder.DropColumn( + name: "PurchaseDateTimeUtc", + table: "TicketGroups"); + + migrationBuilder.RenameColumn( + name: "CancellationComment", + table: "VehicleEnrollments", + newName: "CancelationComment"); + + migrationBuilder.AddColumn( + name: "IsMissed", + table: "Tickets", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsReturned", + table: "Tickets", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "PurchaseDateTimeUtc", + table: "Tickets", + type: "timestamp with time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + } +} diff --git a/Server/Migrations/ApplicationDbContextModelSnapshot.cs b/Server/Migrations/ApplicationDbContextModelSnapshot.cs index 1400139..7a43def 100644 --- a/Server/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Server/Migrations/ApplicationDbContextModelSnapshot.cs @@ -179,7 +179,7 @@ namespace Server.Migrations b.HasIndex("CityId"); - b.ToTable("Addresses", (string)null); + b.ToTable("Addresses"); }); modelBuilder.Entity("Server.Models.City", b => @@ -201,7 +201,7 @@ namespace Server.Migrations b.HasIndex("StateId"); - b.ToTable("Cities", (string)null); + b.ToTable("Cities"); }); modelBuilder.Entity("Server.Models.Company", b => @@ -225,7 +225,7 @@ namespace Server.Migrations b.HasIndex("OwnerId") .IsUnique(); - b.ToTable("Companies", (string)null); + b.ToTable("Companies"); }); modelBuilder.Entity("Server.Models.CompanyDriver", b => @@ -241,7 +241,7 @@ namespace Server.Migrations b.HasIndex("DriverId") .IsUnique(); - b.ToTable("CompanyDrivers", (string)null); + b.ToTable("CompanyDrivers"); }); modelBuilder.Entity("Server.Models.Country", b => @@ -262,7 +262,7 @@ namespace Server.Migrations b.HasKey("Id"); - b.ToTable("Countries", (string)null); + b.ToTable("Countries"); }); modelBuilder.Entity("Server.Models.Review", b => @@ -295,7 +295,7 @@ namespace Server.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("Reviews", (string)null); + b.ToTable("Reviews"); }); modelBuilder.Entity("Server.Models.Route", b => @@ -312,7 +312,7 @@ namespace Server.Migrations b.HasKey("Id"); - b.ToTable("Routes", (string)null); + b.ToTable("Routes"); }); modelBuilder.Entity("Server.Models.RouteAddress", b => @@ -341,7 +341,7 @@ namespace Server.Migrations b.HasIndex("RouteId"); - b.ToTable("RouteAddresses", (string)null); + b.ToTable("RouteAddresses"); }); modelBuilder.Entity("Server.Models.RouteAddressDetails", b => @@ -373,7 +373,7 @@ namespace Server.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("RouteAddressDetails", (string)null); + b.ToTable("RouteAddressDetails"); }); modelBuilder.Entity("Server.Models.State", b => @@ -395,7 +395,7 @@ namespace Server.Migrations b.HasIndex("CountryId"); - b.ToTable("States", (string)null); + b.ToTable("States"); }); modelBuilder.Entity("Server.Models.Ticket", b => @@ -409,18 +409,9 @@ namespace Server.Migrations b.Property("FirstRouteAddressId") .HasColumnType("integer"); - b.Property("IsMissed") - .HasColumnType("boolean"); - - b.Property("IsReturned") - .HasColumnType("boolean"); - b.Property("LastRouteAddressId") .HasColumnType("integer"); - b.Property("PurchaseDateTimeUtc") - .HasColumnType("timestamp with time zone"); - b.Property("TicketGroupId") .HasColumnType("integer"); @@ -433,7 +424,7 @@ namespace Server.Migrations b.HasIndex("VehicleEnrollmentId"); - b.ToTable("Tickets", (string)null); + b.ToTable("Tickets"); }); modelBuilder.Entity("Server.Models.TicketGroup", b => @@ -444,6 +435,12 @@ namespace Server.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("IsReturned") + .HasColumnType("boolean"); + + b.Property("PurchaseDateTimeUtc") + .HasColumnType("timestamp with time zone"); + b.Property("UserId") .IsRequired() .HasColumnType("text"); @@ -452,7 +449,7 @@ namespace Server.Migrations b.HasIndex("UserId"); - b.ToTable("TicketGroups", (string)null); + b.ToTable("TicketGroups"); }); modelBuilder.Entity("Server.Models.User", b => @@ -578,7 +575,7 @@ namespace Server.Migrations b.HasIndex("CompanyId"); - b.ToTable("Vehicles", (string)null); + b.ToTable("Vehicles"); }); modelBuilder.Entity("Server.Models.VehicleEnrollment", b => @@ -589,7 +586,7 @@ namespace Server.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("CancelationComment") + b.Property("CancellationComment") .HasColumnType("text"); b.Property("DelayTimeSpan") @@ -613,7 +610,7 @@ namespace Server.Migrations b.HasIndex("VehicleId"); - b.ToTable("VehicleEnrollments", (string)null); + b.ToTable("VehicleEnrollments"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -819,7 +816,7 @@ namespace Server.Migrations modelBuilder.Entity("Server.Models.User", b => { - b.OwnsMany("Server.Models.User.RefreshTokens#Server.Models.RefreshToken", "RefreshTokens", b1 => + b.OwnsMany("Server.Models.RefreshToken", "RefreshTokens", b1 => { b1.Property("UserId") .HasColumnType("text"); @@ -845,7 +842,7 @@ namespace Server.Migrations b1.HasKey("UserId", "Id"); - b1.ToTable("RefreshToken", (string)null); + b1.ToTable("RefreshToken"); b1.WithOwner() .HasForeignKey("UserId"); @@ -933,8 +930,7 @@ namespace Server.Migrations b.Navigation("Company") .IsRequired(); - b.Navigation("Employer") - .IsRequired(); + b.Navigation("Employer"); b.Navigation("Reviews"); diff --git a/Server/Models/Company.cs b/Server/Models/Company.cs index 6a54353..613f561 100644 --- a/Server/Models/Company.cs +++ b/Server/Models/Company.cs @@ -17,7 +17,7 @@ public class Company public virtual IList Vehicles { get; set; } = null!; public virtual IList CompanyDrivers { get; set; } = null!; - public int GetTotalEnrollmentCount(DateTime fromDate, DateTime toDate) + public int GetTotalEnrollmentCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -25,14 +25,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteEnrollmentCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteEnrollmentCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public int GetTotalCanceledEnrollmentCount(DateTime fromDate, DateTime toDate) + public int GetTotalCanceledEnrollmentCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -40,14 +40,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteCanceledEnrollmentCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteCanceledEnrollmentCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public int GetTotalSoldTicketCount(DateTime fromDate, DateTime toDate) + public int GetTotalSoldTicketCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -55,14 +55,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteSoldTicketCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteSoldTicketCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public int GetTotalReturnedTicketCount(DateTime fromDate, DateTime toDate) + public int GetTotalReturnedTicketCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -70,14 +70,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteReturnedTicketCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteReturnedTicketCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public int GetTotalIndirectTicketCount(DateTime fromDate, DateTime toDate) + public int GetTotalIndirectTicketCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -85,14 +85,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteIndirectTicketCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteIndirectTicketCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public int GetTotalReturnedIndirectTicketCount(DateTime fromDate, DateTime toDate) + public int GetTotalReturnedIndirectTicketCount(DateTime fromDateUtc, DateTime toDateUtc) { int result = 0; @@ -100,14 +100,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteReturnedIndirectTicketCount(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteReturnedIndirectTicketCount(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public double GetTotalRevenue(DateTime fromDate, DateTime toDate) + public double GetTotalRevenue(DateTime fromDateUtc, DateTime toDateUtc) { double result = 0; @@ -115,14 +115,14 @@ public class Company { foreach (var enrollment in vehicle.VehicleEnrollments) { - result += vehicle.GetRouteTotalRevenue(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteTotalRevenue(fromDateUtc, toDateUtc, enrollment.RouteId); } } return result; } - public double GetTotalAverageRating(DateTime fromDate, DateTime toDate) + public double GetTotalAverageRating(DateTime fromDateUtc, DateTime toDateUtc) { double result = 0; int enrollmentCount = 0; @@ -136,7 +136,7 @@ public class Company continue; } - result += vehicle.GetRouteAverageRating(fromDate, toDate, enrollment.RouteId); + result += vehicle.GetRouteAverageRating(fromDateUtc, toDateUtc, enrollment.RouteId); enrollmentCount++; } } diff --git a/Server/Models/Route.cs b/Server/Models/Route.cs index 24e4463..270702b 100644 --- a/Server/Models/Route.cs +++ b/Server/Models/Route.cs @@ -35,7 +35,7 @@ public class Route foreach (var enrollment in VehicleEnrollments) { result += enrollment.Tickets.Count(t => - !t.IsReturned && + !t.TicketGroup.IsReturned && t.VehicleEnrollment.DepartureDateTimeUtc >= fromDate && t.VehicleEnrollment.DepartureDateTimeUtc <= toDate && t.VehicleEnrollment.Vehicle.CompanyId == companyId); } @@ -52,7 +52,7 @@ public class Route foreach (var enrollment in VehicleEnrollments) { - result += enrollment.Tickets.Count(t => !t.IsReturned && + result += enrollment.Tickets.Count(t => !t.TicketGroup.IsReturned && t.FirstRouteAddressId != departureAddressId || t.LastRouteAddressId != arrivalAddressId && t.VehicleEnrollment.DepartureDateTimeUtc >= fromDate && t.VehicleEnrollment.DepartureDateTimeUtc <= toDate && diff --git a/Server/Models/Ticket.cs b/Server/Models/Ticket.cs index aa9d89a..f3c4a90 100644 --- a/Server/Models/Ticket.cs +++ b/Server/Models/Ticket.cs @@ -16,11 +16,8 @@ public class Ticket public int VehicleEnrollmentId { get; set; } public VehicleEnrollment VehicleEnrollment { get; set; } = null!; - public DateTime PurchaseDateTimeUtc { get; set; } = DateTime.UtcNow; public int FirstRouteAddressId { get; set; } public int LastRouteAddressId { get; set; } - public bool IsReturned { get; set; } = false; - public bool IsMissed { get; set; } = false; public double GetCost() { diff --git a/Server/Models/TicketGroup.cs b/Server/Models/TicketGroup.cs index b7c22b7..233b291 100644 --- a/Server/Models/TicketGroup.cs +++ b/Server/Models/TicketGroup.cs @@ -6,6 +6,9 @@ public class TicketGroup { [Key] public int Id { get; set; } + + public DateTime PurchaseDateTimeUtc { get; set; } = DateTime.UtcNow; + public bool IsReturned { get; set; } = false; public string UserId { get; set; } = null!; public User User { get; set; } = null!; diff --git a/Server/Models/Vehicle.cs b/Server/Models/Vehicle.cs index f4d620c..9662bb7 100644 --- a/Server/Models/Vehicle.cs +++ b/Server/Models/Vehicle.cs @@ -52,7 +52,7 @@ public class Vehicle foreach (var enrollment in enrollments) { - result += enrollment.Tickets.Count(t => !t.IsReturned); + result += enrollment.Tickets.Count(t => !t.TicketGroup.IsReturned); } return result; @@ -68,7 +68,7 @@ public class Vehicle foreach (var enrollment in enrollments) { - result += enrollment.Tickets.Count(t => t.IsReturned); + result += enrollment.Tickets.Count(t => t.TicketGroup.IsReturned); } return result; @@ -87,7 +87,7 @@ public class Vehicle var departureRouteAddressId = enrollment.Route.RouteAddresses.First().AddressId; var arrivalRouteAddressId = enrollment.Route.RouteAddresses.Last().AddressId; - result += enrollment.Tickets.Count(t => !t.IsReturned && + result += enrollment.Tickets.Count(t => !t.TicketGroup.IsReturned && t.FirstRouteAddressId != departureRouteAddressId || t.LastRouteAddressId != arrivalRouteAddressId); } @@ -108,7 +108,7 @@ public class Vehicle var departureRouteAddressId = enrollment.Route.RouteAddresses.First().AddressId; var arrivalRouteAddressId = enrollment.Route.RouteAddresses.Last().AddressId; - result += enrollment.Tickets.Count(t => t.IsReturned && + result += enrollment.Tickets.Count(t => t.TicketGroup.IsReturned && (t.FirstRouteAddressId != departureRouteAddressId || t.LastRouteAddressId != arrivalRouteAddressId)); } diff --git a/Server/Models/VehicleEnrollment.cs b/Server/Models/VehicleEnrollment.cs index 76b5e12..3fc29c9 100644 --- a/Server/Models/VehicleEnrollment.cs +++ b/Server/Models/VehicleEnrollment.cs @@ -23,7 +23,7 @@ public class VehicleEnrollment public TimeSpan? DelayTimeSpan { get; set; } public bool IsCanceled { get; set; } = false; - public string? CancelationComment { get; set; } = null!; + public string? CancellationComment { get; set; } = null!; public IList Tickets { get; set; } = null!; public IList Reviews { get; set; } = null!; diff --git a/Server/Services/ReportService.cs b/Server/Services/ReportService.cs index a2a3c93..bb78b97 100644 --- a/Server/Services/ReportService.cs +++ b/Server/Services/ReportService.cs @@ -199,7 +199,7 @@ public class ReportService : IReportService row.Cells[9].MergeRight = 2; row.Cells[9].MergeDown = 1; - row.Cells[9].AddParagraph($"{ticketGroup.Tickets.First().PurchaseDateTimeUtc:dd.MM.yyyy HH:mm:ss}"); + row.Cells[9].AddParagraph($"{ticketGroup.PurchaseDateTimeUtc:dd.MM.yyyy HH:mm:ss}"); row = table.AddRow(); diff --git a/Server/Services/StatisticsService.cs b/Server/Services/StatisticsService.cs index 5167b86..87eb47e 100644 --- a/Server/Services/StatisticsService.cs +++ b/Server/Services/StatisticsService.cs @@ -46,7 +46,7 @@ public class StatisticsService : IStatisticsService var dbTicketGroupsArray = await _dbContext.TicketGroups .Include(tg => tg.Tickets) - .Where(tg => tg.Tickets.First().PurchaseDateTimeUtc >= fromDateUtc) + .Where(tg => tg.PurchaseDateTimeUtc >= fromDateUtc) .ToArrayAsync(); var depArrCombCountDict = new Dictionary<(int, int), int>(); @@ -163,7 +163,7 @@ public class StatisticsService : IStatisticsService { User = u, TicketGroups = u.TicketGroups.Where(tg => - tg.Tickets.First().PurchaseDateTimeUtc >= fromDateUtc) + tg.PurchaseDateTimeUtc >= fromDateUtc) }) .OrderByDescending(o => o.TicketGroups.Count()) .Take(parameters.Amount) @@ -287,7 +287,7 @@ public class StatisticsService : IStatisticsService var dbTicketGroupsArray = await _dbContext.TicketGroups .Include(tg => tg.Tickets) - .Where(tg => tg.Tickets.First().PurchaseDateTimeUtc >= fromDateUtc) + .Where(tg => tg.PurchaseDateTimeUtc >= fromDateUtc) .ToArrayAsync(); // Count appearances for each address id diff --git a/Server/Services/TicketManagementService.cs b/Server/Services/TicketManagementService.cs index 3edcde1..83da07b 100644 --- a/Server/Services/TicketManagementService.cs +++ b/Server/Services/TicketManagementService.cs @@ -78,8 +78,8 @@ public class TicketManagementService : ITicketManagementService } tickets = tickets.Where(t => - t.PurchaseDateTimeUtc >= fromDateTime.Value.ToUniversalTime() && - t.PurchaseDateTimeUtc <= toDateTime.Value.ToUniversalTime()); + t.TicketGroup.PurchaseDateTimeUtc >= fromDateTime.Value.ToUniversalTime() && + t.TicketGroup.PurchaseDateTimeUtc <= toDateTime.Value.ToUniversalTime()); } void FilterByTicketReturnedState(ref IQueryable tickets, @@ -90,7 +90,7 @@ public class TicketManagementService : ITicketManagementService return; } - tickets = tickets.Where(t => t.IsReturned == isReturned); + tickets = tickets.Where(t => t.TicketGroup.IsReturned == isReturned); } // TODO: change TicketParameters diff --git a/Server/Services/VehicleEnrollmentManagementService.cs b/Server/Services/VehicleEnrollmentManagementService.cs index d38a9c5..b28104a 100644 --- a/Server/Services/VehicleEnrollmentManagementService.cs +++ b/Server/Services/VehicleEnrollmentManagementService.cs @@ -97,7 +97,7 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe } enrollment = enrollment.Where(e => - e.CancelationComment != null && e.CancelationComment.ToLower().Contains(search.ToLower())); + e.CancellationComment != null && e.CancellationComment.ToLower().Contains(search.ToLower())); } void FilterByEnrollmentVehicleId(ref IQueryable enrollments, @@ -205,7 +205,7 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe } enrollment = enrollment.Where(e => - e.CancelationComment != null && e.CancelationComment.ToLower().Contains(search.ToLower())); + e.CancellationComment != null && e.CancellationComment.ToLower().Contains(search.ToLower())); } void FilterByEnrollmentVehicleId(ref IQueryable enrollments, diff --git a/SharedModels/DataTransferObjects/TicketDto.cs b/SharedModels/DataTransferObjects/TicketDto.cs index eff255f..8af8fcd 100644 --- a/SharedModels/DataTransferObjects/TicketDto.cs +++ b/SharedModels/DataTransferObjects/TicketDto.cs @@ -8,14 +8,7 @@ public class TicketDto : CreateTicketDto public string UserId { get; set; } = null!; - [DataType(DataType.DateTime)] - public DateTime PurchaseDateTimeUtc { get; set; } - public InReviewVehicleEnrollmentDto VehicleEnrollment { get; set; } = null!; - - public bool IsReturned { get; set; } = false; - - public bool IsMissed { get; set; } = false; } public class CreateTicketDto @@ -43,16 +36,6 @@ public class UpdateTicketDto [Required] public int VehicleEnrollmentId { get; set; } - - [Required] - [DataType(DataType.DateTime)] - public DateTime PurchaseDateTime { get; set; } - - [Required] - public bool IsReturned { get; set; } = false; - - [Required] - public bool IsMissed { get; set; } = false; } public class CreateInTicketGroupTicketDto diff --git a/SharedModels/DataTransferObjects/TicketGroupDto.cs b/SharedModels/DataTransferObjects/TicketGroupDto.cs index 40850c5..eb21cff 100644 --- a/SharedModels/DataTransferObjects/TicketGroupDto.cs +++ b/SharedModels/DataTransferObjects/TicketGroupDto.cs @@ -5,6 +5,11 @@ namespace SharedModels.DataTransferObjects; public class TicketGroupDto : CreateTicketGroupDto { public int Id { get; set; } + + [DataType(DataType.DateTime)] + public DateTime PurchaseDateTime { get; set; } + + public bool IsReturned { get; set; } } public class CreateTicketGroupDto @@ -20,6 +25,11 @@ public class UpdateTicketGroupDto [Required] public string UserId { get; set; } = null!; + + [DataType(DataType.DateTime)] + public DateTime PurchaseDateTime { get; set; } + + public bool IsReturned { get; set; } = false; } public class TicketGroupWithTicketsDto diff --git a/SharedModels/QueryParameters/Objects/TicketGroupParameters.cs b/SharedModels/QueryParameters/Objects/TicketGroupParameters.cs index 6aeb624..0184161 100644 --- a/SharedModels/QueryParameters/Objects/TicketGroupParameters.cs +++ b/SharedModels/QueryParameters/Objects/TicketGroupParameters.cs @@ -2,12 +2,14 @@ namespace SharedModels.QueryParameters.Objects; public class TicketGroupParameters : ParametersBase { - public const string DefaultFields = "id,userId"; + public const string DefaultFields = "id,purchaseDateTime,isReturned,userId"; public TicketGroupParameters() { Fields = DefaultFields; } - + public DateTime? FromPurchaseDateTimeUtc { get; set; } + public DateTime? ToPurchaseDateTimeUtc { get; set; } + public bool? IsReturned { get; set; } public string? UserId { get; set; } } \ No newline at end of file diff --git a/SharedModels/QueryParameters/Objects/TicketParameters.cs b/SharedModels/QueryParameters/Objects/TicketParameters.cs index 96b4a1e..06e0c61 100644 --- a/SharedModels/QueryParameters/Objects/TicketParameters.cs +++ b/SharedModels/QueryParameters/Objects/TicketParameters.cs @@ -2,8 +2,7 @@ namespace SharedModels.QueryParameters.Objects; public class TicketParameters : ParametersBase { - public const string DefaultFields = "id,userId,vehicleEnrollmentId,vehicleEnrollment," + - "purchaseDateTimeUtc,isReturned,isMissed"; + public const string DefaultFields = "id,userId,vehicleEnrollmentId,vehicleEnrollment"; public TicketParameters() {