refactor: move some fields in models, add review model
This commit is contained in:
parent
8bf18c948e
commit
0929200fdb
@ -12,17 +12,17 @@ public class ApplicationDbContext : IdentityDbContext<User>
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Company> Companies { get; set; }
|
||||
public DbSet<Vehicle> Vehicles { get; set; }
|
||||
public DbSet<VehicleEnrollment> VehicleEnrollments { get; set; }
|
||||
public DbSet<Route> Routes { get; set; }
|
||||
public DbSet<RouteAddress> RouteAddresses { get; set; }
|
||||
public DbSet<Address> Addresses { get; set; }
|
||||
public DbSet<City> Cities { get; set; }
|
||||
public DbSet<State> States { get; set; }
|
||||
public DbSet<Country> Countries { get; set; }
|
||||
|
||||
public DbSet<Ticket> Tickets { get; set; }
|
||||
public DbSet<Company> Companies { get; set; } = null!;
|
||||
public DbSet<Vehicle> Vehicles { get; set; } = null!;
|
||||
public DbSet<VehicleEnrollment> VehicleEnrollments { get; set; } = null!;
|
||||
public DbSet<Route> Routes { get; set; } = null!;
|
||||
public DbSet<RouteAddress> RouteAddresses { get; set; } = null!;
|
||||
public DbSet<Address> Addresses { get; set; } = null!;
|
||||
public DbSet<City> Cities { get; set; } = null!;
|
||||
public DbSet<State> States { get; set; } = null!;
|
||||
public DbSet<Country> Countries { get; set; } = null!;
|
||||
public DbSet<Ticket> Tickets { get; set; } = null!;
|
||||
public DbSet<Review> Reviews { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -33,5 +33,8 @@ public class ApplicationDbContext : IdentityDbContext<User>
|
||||
|
||||
modelBuilder.Entity<Ticket>()
|
||||
.HasKey(t => new {t.UserId, t.VehicleEnrollmentId});
|
||||
|
||||
modelBuilder.Entity<Review>()
|
||||
.HasKey(t => new {t.UserId, t.VehicleEnrollmentId});
|
||||
}
|
||||
}
|
772
Server/Migrations/20221103173520_Add_Rating_Small_Refactor.Designer.cs
generated
Normal file
772
Server/Migrations/20221103173520_Add_Rating_Small_Refactor.Designer.cs
generated
Normal file
@ -0,0 +1,772 @@
|
||||
// <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("20221103173520_Add_Rating_Small_Refactor")]
|
||||
partial class Add_Rating_Small_Refactor
|
||||
{
|
||||
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");
|
||||
|
||||
b.ToTable("Companies");
|
||||
});
|
||||
|
||||
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<string>("UserId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("VehicleEnrollmentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId", "VehicleEnrollmentId");
|
||||
|
||||
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>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("AddressId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("CostToNextCity")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("Order")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<TimeSpan>("TimeSpanToNextCity")
|
||||
.HasColumnType("interval");
|
||||
|
||||
b.Property<TimeSpan>("WaitTimeSpan")
|
||||
.HasColumnType("interval");
|
||||
|
||||
b.HasKey("RouteId", "AddressId");
|
||||
|
||||
b.HasIndex("AddressId");
|
||||
|
||||
b.ToTable("RouteAddresses");
|
||||
});
|
||||
|
||||
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<string>("UserId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("VehicleEnrollmentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsReturned")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTime>("PurchaseDateTimeUtc")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("UserId", "VehicleEnrollmentId");
|
||||
|
||||
b.HasIndex("VehicleEnrollmentId");
|
||||
|
||||
b.ToTable("Tickets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.User", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("AccessFailedCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<bool>("EmailConfirmed")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.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>("NormalizedUserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.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.Property<string>("UserName")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasDatabaseName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("UserNameIndex");
|
||||
|
||||
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>("CancelationComment")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<TimeSpan>("DelayTimeSpan")
|
||||
.HasColumnType("interval");
|
||||
|
||||
b.Property<DateOnly>("DepartureDateOnly")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<TimeOnly>("DepartureTimeOnlyUtc")
|
||||
.HasColumnType("time without 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")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Review", b =>
|
||||
{
|
||||
b.HasOne("Server.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment")
|
||||
.WithMany()
|
||||
.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.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.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment")
|
||||
.WithMany()
|
||||
.HasForeignKey("VehicleEnrollmentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
|
||||
b.Navigation("VehicleEnrollment");
|
||||
});
|
||||
|
||||
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>("Created")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b1.Property<DateTime>("Expires")
|
||||
.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()
|
||||
.HasForeignKey("RouteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Server.Models.Vehicle", "Vehicle")
|
||||
.WithMany()
|
||||
.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("Vehicles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Country", b =>
|
||||
{
|
||||
b.Navigation("States");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Route", b =>
|
||||
{
|
||||
b.Navigation("RouteAddresses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.State", b =>
|
||||
{
|
||||
b.Navigation("Cities");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
171
Server/Migrations/20221103173520_Add_Rating_Small_Refactor.cs
Normal file
171
Server/Migrations/20221103173520_Add_Rating_Small_Refactor.cs
Normal file
@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Server.Migrations
|
||||
{
|
||||
public partial class Add_Rating_Small_Refactor : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IntendedDepartureTimeOnlyUtc",
|
||||
table: "Routes");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasBelts",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasClimateControl",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasOutlet",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasStewardess",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasTV",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasWC",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "HasWiFi",
|
||||
table: "Vehicles",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CancelationComment",
|
||||
table: "VehicleEnrollments",
|
||||
type: "text",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<TimeOnly>(
|
||||
name: "DepartureTimeOnlyUtc",
|
||||
table: "VehicleEnrollments",
|
||||
type: "time without time zone",
|
||||
nullable: false,
|
||||
defaultValue: new TimeOnly(0, 0, 0));
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsCanceled",
|
||||
table: "VehicleEnrollments",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Reviews",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<string>(type: "text", nullable: false),
|
||||
VehicleEnrollmentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Rating = table.Column<int>(type: "integer", nullable: false),
|
||||
Comment = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Reviews", x => new { x.UserId, x.VehicleEnrollmentId });
|
||||
table.ForeignKey(
|
||||
name: "FK_Reviews_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Reviews_VehicleEnrollments_VehicleEnrollmentId",
|
||||
column: x => x.VehicleEnrollmentId,
|
||||
principalTable: "VehicleEnrollments",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Reviews_VehicleEnrollmentId",
|
||||
table: "Reviews",
|
||||
column: "VehicleEnrollmentId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Reviews");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasBelts",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasClimateControl",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasOutlet",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasStewardess",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasTV",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasWC",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HasWiFi",
|
||||
table: "Vehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CancelationComment",
|
||||
table: "VehicleEnrollments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DepartureTimeOnlyUtc",
|
||||
table: "VehicleEnrollments");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsCanceled",
|
||||
table: "VehicleEnrollments");
|
||||
|
||||
migrationBuilder.AddColumn<TimeOnly>(
|
||||
name: "IntendedDepartureTimeOnlyUtc",
|
||||
table: "Routes",
|
||||
type: "time without time zone",
|
||||
nullable: false,
|
||||
defaultValue: new TimeOnly(0, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
@ -248,6 +248,28 @@ namespace Server.Migrations
|
||||
b.ToTable("Countries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Review", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("VehicleEnrollmentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Comment")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Rating")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserId", "VehicleEnrollmentId");
|
||||
|
||||
b.HasIndex("VehicleEnrollmentId");
|
||||
|
||||
b.ToTable("Reviews");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Route", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -256,9 +278,6 @@ namespace Server.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<TimeOnly>("IntendedDepartureTimeOnlyUtc")
|
||||
.HasColumnType("time without time zone");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -422,6 +441,27 @@ namespace Server.Migrations
|
||||
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");
|
||||
@ -445,12 +485,22 @@ namespace Server.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CancelationComment")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<TimeSpan>("DelayTimeSpan")
|
||||
.HasColumnType("interval");
|
||||
|
||||
b.Property<DateOnly>("DepartureDateOnly")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<TimeOnly>("DepartureTimeOnlyUtc")
|
||||
.HasColumnType("time without time zone");
|
||||
|
||||
b.Property<bool>("IsCanceled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
@ -550,6 +600,25 @@ namespace Server.Migrations
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.Review", b =>
|
||||
{
|
||||
b.HasOne("Server.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Server.Models.VehicleEnrollment", "VehicleEnrollment")
|
||||
.WithMany()
|
||||
.HasForeignKey("VehicleEnrollmentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
|
||||
b.Navigation("VehicleEnrollment");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Server.Models.RouteAddress", b =>
|
||||
{
|
||||
b.HasOne("Server.Models.Address", "Address")
|
||||
|
17
Server/Models/Review.cs
Normal file
17
Server/Models/Review.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Server.Models;
|
||||
|
||||
public class Review
|
||||
{
|
||||
[ForeignKey("UserId")]
|
||||
public string UserId { get; set; } = null!;
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
[ForeignKey("VehicleEnrollmentId")]
|
||||
public int VehicleEnrollmentId { get; set; }
|
||||
public VehicleEnrollment VehicleEnrollment { get; set; } = null!;
|
||||
|
||||
public int Rating { get; set; }
|
||||
public string Comment { get; set; } = null!;
|
||||
}
|
@ -9,7 +9,6 @@ public class Route
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Type { get; set; } = null!;
|
||||
public TimeOnly IntendedDepartureTimeOnlyUtc { get; set; }
|
||||
|
||||
public virtual IList<RouteAddress> RouteAddresses { get; set; } = null!;
|
||||
}
|
@ -15,4 +15,12 @@ public class Vehicle
|
||||
[ForeignKey("CompanyId")]
|
||||
public int CompanyId { get; set; }
|
||||
public Company Company { get; set; } = null!;
|
||||
|
||||
public bool HasClimateControl { get; set; }
|
||||
public bool HasWiFi { get; set; }
|
||||
public bool HasWC { get; set; }
|
||||
public bool HasStewardess { get; set; }
|
||||
public bool HasTV { get; set; }
|
||||
public bool HasOutlet { get; set; }
|
||||
public bool HasBelts { get; set; }
|
||||
}
|
@ -17,5 +17,10 @@ public class VehicleEnrollment
|
||||
public Route Route { get; set; } = null!;
|
||||
|
||||
public DateOnly DepartureDateOnly { get; set; }
|
||||
public TimeOnly DepartureTimeOnlyUtc { get; set; }
|
||||
|
||||
public TimeSpan DelayTimeSpan { get; set; }
|
||||
|
||||
public bool IsCanceled {get; set; }
|
||||
public string CancelationComment { get; set; } = null!;
|
||||
}
|
Loading…
Reference in New Issue
Block a user