Adding IDs to models
This commit is contained in:
parent
ccea3009a9
commit
94d3a56ef9
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoCatCore.Model;
|
using AutoCatCore.Model;
|
||||||
using AutoCatCore.Services.Storage;
|
using AutoCatCore.Services.Storage;
|
||||||
@ -19,6 +20,16 @@ public class HistoryViewModel: ViewModelBase
|
|||||||
|
|
||||||
public async Task AddVehicle(Vehicle vehicle)
|
public async Task AddVehicle(Vehicle vehicle)
|
||||||
{
|
{
|
||||||
await _storageService.AddVehicle(vehicle);
|
try
|
||||||
|
{
|
||||||
|
await _storageService.AddVehicle(vehicle);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Exception: {ex.Message}");
|
||||||
|
Console.WriteLine($"Inner exception: {ex.InnerException?.Message}");
|
||||||
|
Console.WriteLine("");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,5 @@ namespace AutoCatCore.Model
|
|||||||
{
|
{
|
||||||
optionsBuilder.UseSqlite("filename=autocat.db");
|
optionsBuilder.UseSqlite("filename=autocat.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
modelBuilder.Entity<Vehicle>().HasOne(v => v.Brand);
|
|
||||||
|
|
||||||
modelBuilder.Entity<VehicleBrand>().HasNoKey().ToView("VehicleBrandView");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ namespace AutoCatCore.Model
|
|||||||
{
|
{
|
||||||
public class Osago
|
public class Osago
|
||||||
{
|
{
|
||||||
[Key]
|
public int Id { get; set; }
|
||||||
public string? Number { get; set; }
|
public string? Number { get; set; }
|
||||||
public double? Date { get; set; }
|
public double? Date { get; set; }
|
||||||
public string? Vin { get; set; }
|
public string? Vin { get; set; }
|
||||||
|
|||||||
@ -7,17 +7,17 @@ namespace AutoCatCore.Model
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
[MaxLength(50)]
|
[MaxLength(50)]
|
||||||
public string Email { get; set; } = email;
|
public string Email { get; init; } = email;
|
||||||
|
|
||||||
[MaxLength(300)]
|
[MaxLength(300)]
|
||||||
public string? Token { get; set; } = token;
|
public string? Token { get; init; } = token;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[MaxLength(300)]
|
[MaxLength(300)]
|
||||||
public string? FirebaseIdToken { get; set; }
|
public string? FirebaseIdToken { get; init; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[MaxLength(300)]
|
[MaxLength(300)]
|
||||||
public string? FirebaseRefreshToken { get; set; }
|
public string? FirebaseRefreshToken { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,8 @@ namespace AutoCatCore.Model
|
|||||||
public VehicleEngine Engine { get; set; }
|
public VehicleEngine Engine { get; set; }
|
||||||
public List<VehiclePhoto> Photos { get; set; }
|
public List<VehiclePhoto> Photos { get; set; }
|
||||||
public List<VehicleEvent> Events { get; set; }
|
public List<VehicleEvent> Events { get; set; }
|
||||||
public List<Osago> OsagoContracts { get; set; } = new List<Osago>();
|
public List<Osago> OsagoContracts { get; set; }
|
||||||
public List<VehicleOwnershipPeriod> OwnershipPeriods { get; set; } = new List<VehicleOwnershipPeriod>();
|
public List<VehicleOwnershipPeriod> OwnershipPeriods { get; set; }
|
||||||
public List<VehicleAd> Ads { get; set; }
|
public List<VehicleAd> Ads { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace AutoCatCore.Model
|
|||||||
{
|
{
|
||||||
public class VehicleAd
|
public class VehicleAd
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
public string Price { get; set; }
|
public string Price { get; set; }
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VehicleBrand
|
public class VehicleBrand
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public VehicleName Name { get; set; }
|
public VehicleName Name { get; set; }
|
||||||
public string Logo { get; set; }
|
public string Logo { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VehicleEngine
|
public class VehicleEngine
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public string Number { get; set; }
|
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; }
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace AutoCatCore.Model
|
|||||||
{
|
{
|
||||||
public class VehicleEvent
|
public class VehicleEvent
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public double Date { get; set; }
|
public double Date { get; set; }
|
||||||
public double Latitude { get; set; }
|
public double Latitude { get; set; }
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VehicleModel
|
public class VehicleModel
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public VehicleName Name { get; set; }
|
public VehicleName Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
namespace AutoCatCore.Model
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace AutoCatCore.Model
|
||||||
{
|
{
|
||||||
public class VehicleName
|
public class VehicleName
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public string Original { get; set; }
|
public string Original { get; set; }
|
||||||
public string Normalized { get; set; }
|
public string Normalized { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VehicleOwnershipPeriod
|
public class VehicleOwnershipPeriod
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public string LastOperation { get; set; }
|
public string LastOperation { get; set; }
|
||||||
public string OwnerType { get; set; }
|
public string OwnerType { get; set; }
|
||||||
public Int64 From { get; set; }
|
public Int64 From { get; set; }
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class VehiclePhoto
|
public class VehiclePhoto
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
public string Brand { get; set; }
|
public string Brand { get; set; }
|
||||||
public string Model { get; set; }
|
public string Model { get; set; }
|
||||||
public double Date { get; set; }
|
public double Date { get; set; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user