Fixing models. Creating initial migration.

This commit is contained in:
Selim Mustafaev 2024-05-08 17:58:45 +03:00
parent 94d3a56ef9
commit 6fad49e260
16 changed files with 1535 additions and 75 deletions

View File

@ -10,20 +10,9 @@ public class HistoryListViewModelMock: ViewModelBase
public HistoryListViewModelMock() public HistoryListViewModelMock()
{ {
var vehicle1 = new Vehicle var vehicle1 = new Vehicle("А007АА761");
{ var vehicle2 = new Vehicle("А007АА761");
Number = "А007АА761" var vehicle3 = new Vehicle("А007АА761");
};
var vehicle2 = new Vehicle
{
Number = "А008АА761"
};
var vehicle3 = new Vehicle
{
Number = "А009АА761"
};
Vehicles = new ObservableCollection<Vehicle> { vehicle1, vehicle2, vehicle3 }; Vehicles = new ObservableCollection<Vehicle> { vehicle1, vehicle2, vehicle3 };
} }

View File

@ -0,0 +1,510 @@
// <auto-generated />
using System;
using AutoCatCore.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AutoCatCore.Migrations
{
[DbContext(typeof(AutoCatDbContext))]
[Migration("20240508141817_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.4");
modelBuilder.Entity("AutoCatCore.Model.Osago", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<string>("Insurant")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Number")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Owner")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("PlateNumber")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Restrictions")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Status")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("UsageRegion")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.Property<string>("Vin")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("Osago");
});
modelBuilder.Entity("AutoCatCore.Model.User", b =>
{
b.Property<string>("Email")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("FirebaseIdToken")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FirebaseRefreshToken")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("Token")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.HasKey("Email");
b.ToTable("Users");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.Property<string>("Number")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<string>("AddedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("AddedDate")
.HasColumnType("REAL");
b.Property<int?>("BrandId")
.HasColumnType("INTEGER");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Color")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("CurrentNumber")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int?>("EngineId")
.HasColumnType("INTEGER");
b.Property<bool?>("IsJapanese")
.HasColumnType("INTEGER");
b.Property<bool?>("IsRightWheel")
.HasColumnType("INTEGER");
b.Property<int?>("ModelId")
.HasColumnType("INTEGER");
b.Property<string>("Pts")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Sts")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<double?>("UpdatedDate")
.HasColumnType("REAL");
b.Property<string>("Vin1")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Vin2")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int?>("Year")
.HasColumnType("INTEGER");
b.HasKey("Number");
b.HasIndex("BrandId");
b.HasIndex("EngineId");
b.HasIndex("ModelId");
b.ToTable("Vehicles");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleAd", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AdDescription")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("City")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasMaxLength(50)
.HasColumnType("REAL");
b.Property<string>("Mileage")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Photos")
.HasColumnType("TEXT");
b.Property<string>("Price")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Region")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleAd");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Logo")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<int?>("NameId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("NameId");
b.ToTable("VehicleBrand");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEngine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("FuelType")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Number")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("PowerHp")
.HasColumnType("REAL");
b.Property<double?>("PowerKw")
.HasColumnType("REAL");
b.Property<int?>("Volume")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("VehicleEngine");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Address")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<double?>("Latitude")
.HasColumnType("REAL");
b.Property<double?>("Longitude")
.HasColumnType("REAL");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleEvent");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("NameId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("NameId");
b.ToTable("VehicleModel");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Normalized")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Original")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("VehicleName");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Building")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Code")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<long?>("From")
.HasColumnType("INTEGER");
b.Property<string>("Inn")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("LastOperation")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Locality")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("OwnerType")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Region")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("RegistrationRegion")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<long?>("To")
.HasColumnType("INTEGER");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleOwnershipPeriod");
});
modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Brand")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<string>("Model")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehiclePhoto");
});
modelBuilder.Entity("AutoCatCore.Model.Osago", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("OsagoContracts")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.HasOne("AutoCatCore.Model.VehicleBrand", "Brand")
.WithMany()
.HasForeignKey("BrandId");
b.HasOne("AutoCatCore.Model.VehicleEngine", "Engine")
.WithMany()
.HasForeignKey("EngineId");
b.HasOne("AutoCatCore.Model.VehicleModel", "Model")
.WithMany()
.HasForeignKey("ModelId");
b.Navigation("Brand");
b.Navigation("Engine");
b.Navigation("Model");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleAd", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Ads")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b =>
{
b.HasOne("AutoCatCore.Model.VehicleName", "Name")
.WithMany()
.HasForeignKey("NameId");
b.Navigation("Name");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Events")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b =>
{
b.HasOne("AutoCatCore.Model.VehicleName", "Name")
.WithMany()
.HasForeignKey("NameId");
b.Navigation("Name");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("OwnershipPeriods")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Photos")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.Navigation("Ads");
b.Navigation("Events");
b.Navigation("OsagoContracts");
b.Navigation("OwnershipPeriods");
b.Navigation("Photos");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,351 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AutoCatCore.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Email = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Token = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
FirebaseIdToken = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
FirebaseRefreshToken = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Email);
});
migrationBuilder.CreateTable(
name: "VehicleEngine",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Number = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Volume = table.Column<int>(type: "INTEGER", nullable: true),
PowerKw = table.Column<double>(type: "REAL", nullable: true),
PowerHp = table.Column<double>(type: "REAL", nullable: true),
FuelType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleEngine", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleName",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Original = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Normalized = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleName", x => x.Id);
});
migrationBuilder.CreateTable(
name: "VehicleBrand",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NameId = table.Column<int>(type: "INTEGER", nullable: true),
Logo = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleBrand", x => x.Id);
table.ForeignKey(
name: "FK_VehicleBrand_VehicleName_NameId",
column: x => x.NameId,
principalTable: "VehicleName",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "VehicleModel",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NameId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleModel", x => x.Id);
table.ForeignKey(
name: "FK_VehicleModel_VehicleName_NameId",
column: x => x.NameId,
principalTable: "VehicleName",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Vehicles",
columns: table => new
{
Number = table.Column<string>(type: "TEXT", maxLength: 10, nullable: false),
CurrentNumber = table.Column<string>(type: "TEXT", maxLength: 10, nullable: true),
Vin1 = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Vin2 = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Sts = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Pts = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
BrandId = table.Column<int>(type: "INTEGER", nullable: true),
ModelId = table.Column<int>(type: "INTEGER", nullable: true),
Color = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Year = table.Column<int>(type: "INTEGER", nullable: true),
Category = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
IsRightWheel = table.Column<bool>(type: "INTEGER", nullable: true),
IsJapanese = table.Column<bool>(type: "INTEGER", nullable: true),
AddedDate = table.Column<double>(type: "REAL", nullable: true),
UpdatedDate = table.Column<double>(type: "REAL", nullable: true),
AddedBy = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
EngineId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Vehicles", x => x.Number);
table.ForeignKey(
name: "FK_Vehicles_VehicleBrand_BrandId",
column: x => x.BrandId,
principalTable: "VehicleBrand",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Vehicles_VehicleEngine_EngineId",
column: x => x.EngineId,
principalTable: "VehicleEngine",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Vehicles_VehicleModel_ModelId",
column: x => x.ModelId,
principalTable: "VehicleModel",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Osago",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Number = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Date = table.Column<double>(type: "REAL", nullable: true),
Vin = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
PlateNumber = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Name = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Status = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Restrictions = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Insurant = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Owner = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
UsageRegion = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Osago", x => x.Id);
table.ForeignKey(
name: "FK_Osago_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleAd",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Url = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true),
Price = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Date = table.Column<double>(type: "REAL", maxLength: 50, nullable: true),
Mileage = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
Region = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
City = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
AdDescription = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
Photos = table.Column<string>(type: "TEXT", nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleAd", x => x.Id);
table.ForeignKey(
name: "FK_VehicleAd_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleEvent",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Date = table.Column<double>(type: "REAL", nullable: true),
Latitude = table.Column<double>(type: "REAL", nullable: true),
Longitude = table.Column<double>(type: "REAL", nullable: true),
Address = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleEvent", x => x.Id);
table.ForeignKey(
name: "FK_VehicleEvent_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehicleOwnershipPeriod",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
LastOperation = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
OwnerType = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
From = table.Column<long>(type: "INTEGER", nullable: true),
To = table.Column<long>(type: "INTEGER", nullable: true),
Region = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
RegistrationRegion = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
Locality = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Code = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Street = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Building = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Inn = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehicleOwnershipPeriod", x => x.Id);
table.ForeignKey(
name: "FK_VehicleOwnershipPeriod_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateTable(
name: "VehiclePhoto",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Brand = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Model = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
Date = table.Column<double>(type: "REAL", nullable: true),
Url = table.Column<string>(type: "TEXT", maxLength: 500, nullable: true),
VehicleNumber = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_VehiclePhoto", x => x.Id);
table.ForeignKey(
name: "FK_VehiclePhoto_Vehicles_VehicleNumber",
column: x => x.VehicleNumber,
principalTable: "Vehicles",
principalColumn: "Number");
});
migrationBuilder.CreateIndex(
name: "IX_Osago_VehicleNumber",
table: "Osago",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleAd_VehicleNumber",
table: "VehicleAd",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleBrand_NameId",
table: "VehicleBrand",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_VehicleEvent_VehicleNumber",
table: "VehicleEvent",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehicleModel_NameId",
table: "VehicleModel",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_VehicleOwnershipPeriod_VehicleNumber",
table: "VehicleOwnershipPeriod",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_VehiclePhoto_VehicleNumber",
table: "VehiclePhoto",
column: "VehicleNumber");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_BrandId",
table: "Vehicles",
column: "BrandId");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_EngineId",
table: "Vehicles",
column: "EngineId");
migrationBuilder.CreateIndex(
name: "IX_Vehicles_ModelId",
table: "Vehicles",
column: "ModelId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Osago");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "VehicleAd");
migrationBuilder.DropTable(
name: "VehicleEvent");
migrationBuilder.DropTable(
name: "VehicleOwnershipPeriod");
migrationBuilder.DropTable(
name: "VehiclePhoto");
migrationBuilder.DropTable(
name: "Vehicles");
migrationBuilder.DropTable(
name: "VehicleBrand");
migrationBuilder.DropTable(
name: "VehicleEngine");
migrationBuilder.DropTable(
name: "VehicleModel");
migrationBuilder.DropTable(
name: "VehicleName");
}
}
}

View File

@ -0,0 +1,507 @@
// <auto-generated />
using System;
using AutoCatCore.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AutoCatCore.Migrations
{
[DbContext(typeof(AutoCatDbContext))]
partial class AutoCatDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.4");
modelBuilder.Entity("AutoCatCore.Model.Osago", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<string>("Insurant")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Number")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Owner")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("PlateNumber")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Restrictions")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Status")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("UsageRegion")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.Property<string>("Vin")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("Osago");
});
modelBuilder.Entity("AutoCatCore.Model.User", b =>
{
b.Property<string>("Email")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("FirebaseIdToken")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FirebaseRefreshToken")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("Token")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.HasKey("Email");
b.ToTable("Users");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.Property<string>("Number")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<string>("AddedBy")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("AddedDate")
.HasColumnType("REAL");
b.Property<int?>("BrandId")
.HasColumnType("INTEGER");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Color")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("CurrentNumber")
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<int?>("EngineId")
.HasColumnType("INTEGER");
b.Property<bool?>("IsJapanese")
.HasColumnType("INTEGER");
b.Property<bool?>("IsRightWheel")
.HasColumnType("INTEGER");
b.Property<int?>("ModelId")
.HasColumnType("INTEGER");
b.Property<string>("Pts")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Sts")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<double?>("UpdatedDate")
.HasColumnType("REAL");
b.Property<string>("Vin1")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Vin2")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int?>("Year")
.HasColumnType("INTEGER");
b.HasKey("Number");
b.HasIndex("BrandId");
b.HasIndex("EngineId");
b.HasIndex("ModelId");
b.ToTable("Vehicles");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleAd", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AdDescription")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("City")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasMaxLength(50)
.HasColumnType("REAL");
b.Property<string>("Mileage")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Photos")
.HasColumnType("TEXT");
b.Property<string>("Price")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Region")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleAd");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Logo")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<int?>("NameId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("NameId");
b.ToTable("VehicleBrand");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEngine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("FuelType")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Number")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("PowerHp")
.HasColumnType("REAL");
b.Property<double?>("PowerKw")
.HasColumnType("REAL");
b.Property<int?>("Volume")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("VehicleEngine");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Address")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<double?>("Latitude")
.HasColumnType("REAL");
b.Property<double?>("Longitude")
.HasColumnType("REAL");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleEvent");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("NameId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("NameId");
b.ToTable("VehicleModel");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleName", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Normalized")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Original")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("VehicleName");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Building")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Code")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<long?>("From")
.HasColumnType("INTEGER");
b.Property<string>("Inn")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("LastOperation")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Locality")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("OwnerType")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Region")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("RegistrationRegion")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("Street")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<long?>("To")
.HasColumnType("INTEGER");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehicleOwnershipPeriod");
});
modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Brand")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double?>("Date")
.HasColumnType("REAL");
b.Property<string>("Model")
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("VehicleNumber")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("VehicleNumber");
b.ToTable("VehiclePhoto");
});
modelBuilder.Entity("AutoCatCore.Model.Osago", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("OsagoContracts")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.HasOne("AutoCatCore.Model.VehicleBrand", "Brand")
.WithMany()
.HasForeignKey("BrandId");
b.HasOne("AutoCatCore.Model.VehicleEngine", "Engine")
.WithMany()
.HasForeignKey("EngineId");
b.HasOne("AutoCatCore.Model.VehicleModel", "Model")
.WithMany()
.HasForeignKey("ModelId");
b.Navigation("Brand");
b.Navigation("Engine");
b.Navigation("Model");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleAd", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Ads")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b =>
{
b.HasOne("AutoCatCore.Model.VehicleName", "Name")
.WithMany()
.HasForeignKey("NameId");
b.Navigation("Name");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Events")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b =>
{
b.HasOne("AutoCatCore.Model.VehicleName", "Name")
.WithMany()
.HasForeignKey("NameId");
b.Navigation("Name");
});
modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("OwnershipPeriods")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b =>
{
b.HasOne("AutoCatCore.Model.Vehicle", null)
.WithMany("Photos")
.HasForeignKey("VehicleNumber");
});
modelBuilder.Entity("AutoCatCore.Model.Vehicle", b =>
{
b.Navigation("Ads");
b.Navigation("Events");
b.Navigation("OsagoContracts");
b.Navigation("OwnershipPeriods");
b.Navigation("Photos");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -5,15 +5,24 @@ namespace AutoCatCore.Model
public class Osago public class Osago
{ {
public int Id { get; set; } public int Id { get; set; }
[MaxLength(50)]
public string? Number { get; set; } public string? Number { get; set; }
public double? Date { get; set; } public double? Date { get; set; }
[MaxLength(50)]
public string? Vin { get; set; } public string? Vin { get; set; }
[MaxLength(50)]
public string? PlateNumber { get; set; } public string? PlateNumber { get; set; }
[MaxLength(100)]
public string? Name { get; set; } public string? Name { get; set; }
[MaxLength(100)]
public string? Status { get; set; } public string? Status { get; set; }
[MaxLength(500)]
public string? Restrictions { get; set; } public string? Restrictions { get; set; }
[MaxLength(100)]
public string? Insurant { get; set; } public string? Insurant { get; set; }
[MaxLength(100)]
public string? Owner { get; set; } public string? Owner { get; set; }
[MaxLength(100)]
public string? UsageRegion { get; set; } public string? UsageRegion { get; set; }
} }
} }

View File

@ -2,30 +2,54 @@
namespace AutoCatCore.Model namespace AutoCatCore.Model
{ {
public class Vehicle public class Vehicle(string number)
{ {
[Key] [Key] [MaxLength(10)]
public string Number { get; set; } public string Number { get; set; } = number;
public string CurrentNumber { get; set; }
public string Vin1 { get; set; } [MaxLength(10)]
public string Vin2 { get; set; } public string? CurrentNumber { get; set; }
public string Sts { get; set; }
public string Pts { get; set; } [MaxLength(50)]
public VehicleBrand Brand { get; set; } public string? Vin1 { get; set; }
public VehicleModel Model { get; set; }
public string Color { get; set; } [MaxLength(50)]
public int Year { get; set; } public string? Vin2 { get; set; }
public string Category { get; set; }
[MaxLength(50)]
public string? Sts { get; set; }
[MaxLength(50)]
public string? Pts { get; set; }
public VehicleBrand? Brand { get; set; }
public VehicleModel? Model { get; set; }
[MaxLength(100)]
public string? Color { get; set; }
public int? Year { get; set; }
[MaxLength(100)]
public string? Category { get; set; }
public bool? IsRightWheel { get; set; } public bool? IsRightWheel { get; set; }
public bool? IsJapanese { get; set; } public bool? IsJapanese { get; set; }
public double AddedDate { get; set; }
public double UpdatedDate { get; set; } public double? AddedDate { get; set; }
public string AddedBy { get; set; }
public VehicleEngine Engine { get; set; } public double? UpdatedDate { get; set; }
public List<VehiclePhoto> Photos { get; set; }
public List<VehicleEvent> Events { get; set; } [MaxLength(100)]
public List<Osago> OsagoContracts { get; set; } public string? AddedBy { get; set; }
public List<VehicleOwnershipPeriod> OwnershipPeriods { get; set; }
public List<VehicleAd> Ads { get; set; } public VehicleEngine? Engine { get; set; }
public List<VehiclePhoto>? Photos { get; set; }
public List<VehicleEvent>? Events { get; set; }
public List<Osago>? OsagoContracts { get; set; }
public List<VehicleOwnershipPeriod>? OwnershipPeriods { get; set; }
public List<VehicleAd>? Ads { get; set; }
} }
} }

View File

@ -5,13 +5,20 @@ namespace AutoCatCore.Model
public class VehicleAd public class VehicleAd
{ {
public int Id { get; set; } public int Id { get; set; }
public string Url { get; set; } [MaxLength(200)]
public string Price { get; set; } public string? Url { get; set; }
public double Date { get; set; } [MaxLength(50)]
public string Mileage { get; set; } public string? Price { get; set; }
public string Region { get; set; } [MaxLength(50)]
public string City { get; set; } public double? Date { get; set; }
public string AdDescription { get; set; } [MaxLength(50)]
public List<string> Photos { get; set; } public string? Mileage { get; set; }
[MaxLength(100)]
public string? Region { get; set; }
[MaxLength(100)]
public string? City { get; set; }
[MaxLength(500)]
public string? AdDescription { get; set; }
public List<string>? Photos { get; set; }
} }
} }

View File

@ -1,9 +1,14 @@
namespace AutoCatCore.Model using System.ComponentModel.DataAnnotations;
namespace AutoCatCore.Model
{ {
public class VehicleBrand public class VehicleBrand
{ {
public int Id { get; set; } public int Id { get; set; }
public VehicleName Name { get; set; }
public string Logo { get; set; } public VehicleName? Name { get; set; }
[MaxLength(200)]
public string? Logo { get; set; }
} }
} }

View File

@ -1,12 +1,21 @@
namespace AutoCatCore.Model using System.ComponentModel.DataAnnotations;
namespace AutoCatCore.Model
{ {
public class VehicleEngine public class VehicleEngine
{ {
public int Id { get; set; } public int Id { get; set; }
public string Number { get; set; }
[MaxLength(100)]
public string? Number { get; set; }
public int? Volume { get; set; } public int? Volume { get; set; }
public double? PowerKw { get; set; } public double? PowerKw { get; set; }
public double? PowerHp { get; set; } public double? PowerHp { get; set; }
public string FuelType { get; set; }
[MaxLength(100)]
public string? FuelType { get; set; }
} }
} }

View File

@ -5,9 +5,14 @@ namespace AutoCatCore.Model
public class VehicleEvent public class VehicleEvent
{ {
public string Id { get; set; } public string Id { get; set; }
public double Date { get; set; }
public double Latitude { get; set; } public double? Date { get; set; }
public double Longitude { get; set; }
public string Address { get; set; } public double? Latitude { get; set; }
public double? Longitude { get; set; }
[MaxLength(100)]
public string? Address { get; set; }
} }
} }

View File

@ -3,6 +3,6 @@
public class VehicleModel public class VehicleModel
{ {
public int Id { get; set; } public int Id { get; set; }
public VehicleName Name { get; set; } public VehicleName? Name { get; set; }
} }
} }

View File

@ -1,11 +1,16 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AutoCatCore.Model namespace AutoCatCore.Model
{ {
public class VehicleName public class VehicleName
{ {
public int Id { get; set; } public int Id { get; set; }
public string Original { get; set; }
public string Normalized { get; set; } [MaxLength(100)]
public string? Original { get; set; }
[MaxLength(100)]
public string? Normalized { get; set; }
} }
} }

View File

@ -1,18 +1,40 @@
namespace AutoCatCore.Model using System.ComponentModel.DataAnnotations;
namespace AutoCatCore.Model
{ {
public class VehicleOwnershipPeriod public class VehicleOwnershipPeriod
{ {
public int Id { get; set; } public int Id { get; set; }
public string LastOperation { get; set; }
public string OwnerType { get; set; } [MaxLength(500)]
public Int64 From { get; set; } public string? LastOperation { get; set; }
public Int64 To { get; set; }
public string Region { get; set; } [MaxLength(100)]
public string RegistrationRegion { get; set; } public string? OwnerType { get; set; }
public string Locality { get; set; }
public string Code { get; set; } public long? From { get; set; }
public string Street { get; set; }
public string Building { get; set; } public long? To { get; set; }
public string Inn { get; set; }
[MaxLength(300)]
public string? Region { get; set; }
[MaxLength(300)]
public string? RegistrationRegion { get; set; }
[MaxLength(100)]
public string? Locality { get; set; }
[MaxLength(100)]
public string? Code { get; set; }
[MaxLength(100)]
public string? Street { get; set; }
[MaxLength(100)]
public string? Building { get; set; }
[MaxLength(100)]
public string? Inn { get; set; }
} }
} }

View File

@ -1,11 +1,20 @@
namespace AutoCatCore.Model using System.ComponentModel.DataAnnotations;
namespace AutoCatCore.Model
{ {
public class VehiclePhoto public class VehiclePhoto
{ {
public int Id { get; set; } public int Id { get; set; }
public string Brand { get; set; }
public string Model { get; set; } [MaxLength(100)]
public double Date { get; set; } public string? Brand { get; set; }
public string Url { get; set; }
[MaxLength(100)]
public string? Model { get; set; }
public double? Date { get; set; }
[MaxLength(500)]
public string? Url { get; set; }
} }
} }

View File

@ -1,5 +1,8 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using AutoCatCore.Model; using AutoCatCore.Model;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace AutoCatCore.Services.Storage; namespace AutoCatCore.Services.Storage;
@ -38,4 +41,9 @@ public class StorageService: IStorageService
await _dbContext.Vehicles.AddAsync(vehicle); await _dbContext.Vehicles.AddAsync(vehicle);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
} }
public T GetVehicles<T>() where T: INotifyCollectionChanged
{
return _dbContext.Vehicles.Local;
}
} }

BIN
AutoCatCore/autocat.db Normal file

Binary file not shown.