fix: move purchaseDateTime and isReturned fields from ticket to ticketGroup

This commit is contained in:
cuqmbr 2023-05-13 15:34:55 +03:00
parent 474a25d522
commit bdb1378868
18 changed files with 1114 additions and 86 deletions

View File

@ -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<Ticket>
{
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
}

View File

@ -0,0 +1,958 @@
// <auto-generated />
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<string>("Id")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("RoleId")
.HasColumnType("text");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("text");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Server.Models.Address", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CityId")
.HasColumnType("integer");
b.Property<double>("Latitude")
.HasColumnType("double precision");
b.Property<double>("Longitude")
.HasColumnType("double precision");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CityId");
b.ToTable("Addresses");
});
modelBuilder.Entity("Server.Models.City", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("StateId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("StateId");
b.ToTable("Cities");
});
modelBuilder.Entity("Server.Models.Company", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OwnerId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("OwnerId")
.IsUnique();
b.ToTable("Companies");
});
modelBuilder.Entity("Server.Models.CompanyDriver", b =>
{
b.Property<int>("CompanyId")
.HasColumnType("integer");
b.Property<string>("DriverId")
.HasColumnType("text");
b.HasKey("CompanyId", "DriverId");
b.HasIndex("DriverId")
.IsUnique();
b.ToTable("CompanyDrivers");
});
modelBuilder.Entity("Server.Models.Country", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Countries");
});
modelBuilder.Entity("Server.Models.Review", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("text");
b.Property<DateTime>("PostDateTimeUtc")
.HasColumnType("timestamp with time zone");
b.Property<int>("Rating")
.HasColumnType("integer");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.Property<int>("VehicleEnrollmentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("VehicleEnrollmentId");
b.ToTable("Reviews");
});
modelBuilder.Entity("Server.Models.Route", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Routes");
});
modelBuilder.Entity("Server.Models.RouteAddress", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AddressId")
.HasColumnType("integer");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<int>("RouteAddressDetailsId")
.HasColumnType("integer");
b.Property<int>("RouteId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AddressId");
b.HasIndex("RouteId");
b.ToTable("RouteAddresses");
});
modelBuilder.Entity("Server.Models.RouteAddressDetails", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("CostToNextCity")
.HasColumnType("double precision");
b.Property<int>("RouteAddressId")
.HasColumnType("integer");
b.Property<TimeSpan>("TimeSpanToNextCity")
.HasColumnType("interval");
b.Property<int>("VehicleEnrollmentId")
.HasColumnType("integer");
b.Property<TimeSpan>("WaitTimeSpan")
.HasColumnType("interval");
b.HasKey("Id");
b.HasIndex("RouteAddressId");
b.HasIndex("VehicleEnrollmentId");
b.ToTable("RouteAddressDetails");
});
modelBuilder.Entity("Server.Models.State", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("CountryId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CountryId");
b.ToTable("States");
});
modelBuilder.Entity("Server.Models.Ticket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("FirstRouteAddressId")
.HasColumnType("integer");
b.Property<int>("LastRouteAddressId")
.HasColumnType("integer");
b.Property<int>("TicketGroupId")
.HasColumnType("integer");
b.Property<int>("VehicleEnrollmentId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TicketGroupId");
b.HasIndex("VehicleEnrollmentId");
b.ToTable("Tickets");
});
modelBuilder.Entity("Server.Models.TicketGroup", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<bool>("IsReturned")
.HasColumnType("boolean");
b.Property<DateTime>("PurchaseDateTimeUtc")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("TicketGroups");
});
modelBuilder.Entity("Server.Models.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<DateTime?>("BirthDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<int?>("Document")
.HasColumnType("integer");
b.Property<string>("DocumentDetails")
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("Gender")
.HasColumnType("integer");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Server.Models.Vehicle", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Capacity")
.HasColumnType("integer");
b.Property<int>("CompanyId")
.HasColumnType("integer");
b.Property<bool>("HasBelts")
.HasColumnType("boolean");
b.Property<bool>("HasClimateControl")
.HasColumnType("boolean");
b.Property<bool>("HasOutlet")
.HasColumnType("boolean");
b.Property<bool>("HasStewardess")
.HasColumnType("boolean");
b.Property<bool>("HasTV")
.HasColumnType("boolean");
b.Property<bool>("HasWC")
.HasColumnType("boolean");
b.Property<bool>("HasWiFi")
.HasColumnType("boolean");
b.Property<string>("Number")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CompanyId");
b.ToTable("Vehicles");
});
modelBuilder.Entity("Server.Models.VehicleEnrollment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("CancellationComment")
.HasColumnType("text");
b.Property<TimeSpan?>("DelayTimeSpan")
.HasColumnType("interval");
b.Property<DateTime>("DepartureDateTimeUtc")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsCanceled")
.HasColumnType("boolean");
b.Property<int>("RouteId")
.HasColumnType("integer");
b.Property<int>("VehicleId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("RouteId");
b.HasIndex("VehicleId");
b.ToTable("VehicleEnrollments");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Server.Models.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Server.Models.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", 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<string>", 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<string>("UserId")
.HasColumnType("text");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property<int>("Id"));
b1.Property<DateTime>("CreationDateTime")
.HasColumnType("timestamp with time zone");
b1.Property<DateTime>("ExpiryDateTime")
.HasColumnType("timestamp with time zone");
b1.Property<DateTime?>("Revoked")
.HasColumnType("timestamp with time zone");
b1.Property<string>("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
}
}
}

View File

@ -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<bool>(
name: "IsReturned",
table: "TicketGroups",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
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<bool>(
name: "IsMissed",
table: "Tickets",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsReturned",
table: "Tickets",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "PurchaseDateTimeUtc",
table: "Tickets",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
}
}

View File

@ -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<int>("FirstRouteAddressId")
.HasColumnType("integer");
b.Property<bool>("IsMissed")
.HasColumnType("boolean");
b.Property<bool>("IsReturned")
.HasColumnType("boolean");
b.Property<int>("LastRouteAddressId")
.HasColumnType("integer");
b.Property<DateTime>("PurchaseDateTimeUtc")
.HasColumnType("timestamp with time zone");
b.Property<int>("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<int>("Id"));
b.Property<bool>("IsReturned")
.HasColumnType("boolean");
b.Property<DateTime>("PurchaseDateTimeUtc")
.HasColumnType("timestamp with time zone");
b.Property<string>("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<int>("Id"));
b.Property<string>("CancelationComment")
b.Property<string>("CancellationComment")
.HasColumnType("text");
b.Property<TimeSpan?>("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<string>", 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<string>("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");

View File

@ -17,7 +17,7 @@ public class Company
public virtual IList<Vehicle> Vehicles { get; set; } = null!;
public virtual IList<CompanyDriver> 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++;
}
}

View File

@ -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 &&

View File

@ -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()
{

View File

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

View File

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

View File

@ -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<Ticket> Tickets { get; set; } = null!;
public IList<Review> Reviews { get; set; } = null!;

View File

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

View File

@ -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 <Id, Count>

View File

@ -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<Ticket> 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

View File

@ -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<VehicleEnrollment> 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<VehicleEnrollment> enrollments,

View File

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

View File

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

View File

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

View File

@ -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()
{