diff --git a/AutoCat/Extensions/DateConverter.cs b/AutoCat/Extensions/DateConverter.cs index 94dac22..2eec40e 100644 --- a/AutoCat/Extensions/DateConverter.cs +++ b/AutoCat/Extensions/DateConverter.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using Avalonia.Data.Converters; @@ -20,6 +21,7 @@ public class DateConverter: IValueConverter return dateTime.ToString("g"); } + [SuppressMessage("ReSharper", "ReturnTypeCanBeNotNullable")] public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotImplementedException(); diff --git a/AutoCat/Mocks/HistoryListViewModelMock.cs b/AutoCat/Mocks/HistoryListViewModelMock.cs index fb4bfe1..203cf7a 100644 --- a/AutoCat/Mocks/HistoryListViewModelMock.cs +++ b/AutoCat/Mocks/HistoryListViewModelMock.cs @@ -10,9 +10,9 @@ public class HistoryListViewModelMock: ViewModelBase public HistoryListViewModelMock() { - var vehicle1 = new Vehicle("А007АА761"); - var vehicle2 = new Vehicle("А007АА761"); - var vehicle3 = new Vehicle("А007АА761"); + var vehicle1 = new Vehicle { Number = "А007АА761" }; + var vehicle2 = new Vehicle { Number = "А007АА761" }; + var vehicle3 = new Vehicle { Number = "А007АА761" }; Vehicles = new ObservableCollection { vehicle1, vehicle2, vehicle3 }; } diff --git a/AutoCat/Pages/HistoryPage.axaml b/AutoCat/Pages/HistoryPage.axaml index 1e9b6f5..68ce8cf 100644 --- a/AutoCat/Pages/HistoryPage.axaml +++ b/AutoCat/Pages/HistoryPage.axaml @@ -5,7 +5,6 @@ xmlns:pages="clr-namespace:AutoCat.Pages" xmlns:utils="using:AutoCat.Utils" xmlns:vm="using:AutoCat.ViewModels" - xmlns:models="using:AutoCatCore.Model" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="AutoCat.Pages.HistoryPage" x:DataType="vm:HistoryViewModel" diff --git a/AutoCat/Pages/SearchPage.axaml.cs b/AutoCat/Pages/SearchPage.axaml.cs index a585ad9..a55d400 100644 --- a/AutoCat/Pages/SearchPage.axaml.cs +++ b/AutoCat/Pages/SearchPage.axaml.cs @@ -1,6 +1,4 @@ -using Avalonia; using Avalonia.Controls; -using Avalonia.Markup.Xaml; namespace AutoCat.Pages; diff --git a/AutoCat/ViewModels/CheckNumberViewModel.cs b/AutoCat/ViewModels/CheckNumberViewModel.cs index 9bb5b66..19940eb 100644 --- a/AutoCat/ViewModels/CheckNumberViewModel.cs +++ b/AutoCat/ViewModels/CheckNumberViewModel.cs @@ -24,7 +24,7 @@ public class CheckNumberViewModel : ViewModelBase #region Commands - public ReactiveCommand CheckCommand { get; } + public ReactiveCommand CheckCommand { get; set; } #endregion diff --git a/AutoCat/ViewModels/HistoryViewModel.cs b/AutoCat/ViewModels/HistoryViewModel.cs index 903dead..8e4575c 100644 --- a/AutoCat/ViewModels/HistoryViewModel.cs +++ b/AutoCat/ViewModels/HistoryViewModel.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.Threading.Tasks; using AutoCat.Utils; using AutoCatCore.Model; @@ -9,7 +9,7 @@ namespace AutoCat.ViewModels; public class HistoryViewModel(IStorageService storageService) : ViewModelBase { - public ObservableCollection Vehicles { get; set; } = storageService.GetVehicles(); + public IEnumerable Vehicles { get; } = storageService.AllVehicles; public async Task AddVehicle(Vehicle vehicle) { diff --git a/AutoCat/Views/PlateView.axaml.cs b/AutoCat/Views/PlateView.axaml.cs index f150a94..b0d6e5f 100644 --- a/AutoCat/Views/PlateView.axaml.cs +++ b/AutoCat/Views/PlateView.axaml.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using AutoCatCore.Model; using Avalonia; using Avalonia.Controls; @@ -45,6 +46,7 @@ public partial class PlateView : UserControl RegionBox.Text = number.Region(); } + [SuppressMessage("ReSharper", "UnusedParameter.Local")] private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) { if(Bounds.Height <= 0) diff --git a/AutoCat/Windows/AuthWindow.axaml b/AutoCat/Windows/AuthWindow.axaml index 48c6bb0..b91b714 100644 --- a/AutoCat/Windows/AuthWindow.axaml +++ b/AutoCat/Windows/AuthWindow.axaml @@ -10,7 +10,7 @@ x:Class="AutoCat.Windows.AuthWindow" x:DataType="vm:AuthWindowViewModel" Title="AuthWindow" - Width="800" Height="600" + Width="900" Height="600" DataContext="{utils:ViewModelProvider vm:AuthWindowViewModel}"> diff --git a/AutoCat/Windows/MainWindow.axaml b/AutoCat/Windows/MainWindow.axaml index dc6a280..038becf 100644 --- a/AutoCat/Windows/MainWindow.axaml +++ b/AutoCat/Windows/MainWindow.axaml @@ -6,7 +6,7 @@ xmlns:utils="using:AutoCat.Utils" xmlns:ui="using:FluentAvalonia.UI.Controls" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - Width="800" + Width="900" Height="600" x:Class="AutoCat.Windows.MainWindow" x:DataType="vm:MainWindowViewModel" diff --git a/AutoCat/Windows/MainWindow.axaml.cs b/AutoCat/Windows/MainWindow.axaml.cs index bf27da2..ecbc43d 100644 --- a/AutoCat/Windows/MainWindow.axaml.cs +++ b/AutoCat/Windows/MainWindow.axaml.cs @@ -1,9 +1,6 @@ -using System; using System.Linq; -using System.Threading.Tasks; using AutoCat.Pages; using AutoCat.ViewModels; -using AutoCatCore.Model; using Avalonia.Controls; using FluentAvalonia.UI.Controls; diff --git a/AutoCatCore/AutoCatCore.csproj b/AutoCatCore/AutoCatCore.csproj index 2558624..156d130 100644 --- a/AutoCatCore/AutoCatCore.csproj +++ b/AutoCatCore/AutoCatCore.csproj @@ -8,12 +8,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/AutoCatCore/Migrations/20240508141817_InitialCreate.Designer.cs b/AutoCatCore/Migrations/20240508141817_InitialCreate.Designer.cs deleted file mode 100644 index c743e90..0000000 --- a/AutoCatCore/Migrations/20240508141817_InitialCreate.Designer.cs +++ /dev/null @@ -1,510 +0,0 @@ -// -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 - { - /// - 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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Insurant") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Number") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Owner") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("PlateNumber") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Restrictions") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Status") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("UsageRegion") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.Property("Vin") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("Osago"); - }); - - modelBuilder.Entity("AutoCatCore.Model.User", b => - { - b.Property("Email") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("FirebaseIdToken") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("FirebaseRefreshToken") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Token") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.HasKey("Email"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("AutoCatCore.Model.Vehicle", b => - { - b.Property("Number") - .HasMaxLength(10) - .HasColumnType("TEXT"); - - b.Property("AddedBy") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("AddedDate") - .HasColumnType("REAL"); - - b.Property("BrandId") - .HasColumnType("INTEGER"); - - b.Property("Category") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Color") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("CurrentNumber") - .HasMaxLength(10) - .HasColumnType("TEXT"); - - b.Property("EngineId") - .HasColumnType("INTEGER"); - - b.Property("IsJapanese") - .HasColumnType("INTEGER"); - - b.Property("IsRightWheel") - .HasColumnType("INTEGER"); - - b.Property("ModelId") - .HasColumnType("INTEGER"); - - b.Property("Pts") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Sts") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("UpdatedDate") - .HasColumnType("REAL"); - - b.Property("Vin1") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Vin2") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AdDescription") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("City") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasMaxLength(50) - .HasColumnType("REAL"); - - b.Property("Mileage") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Photos") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Region") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Url") - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleAd"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Logo") - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("NameId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("NameId"); - - b.ToTable("VehicleBrand"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleEngine", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FuelType") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Number") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("PowerHp") - .HasColumnType("REAL"); - - b.Property("PowerKw") - .HasColumnType("REAL"); - - b.Property("Volume") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("VehicleEngine"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("Address") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleEvent"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("NameId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("NameId"); - - b.ToTable("VehicleModel"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleName", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Normalized") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Original") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("VehicleName"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Building") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Code") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("From") - .HasColumnType("INTEGER"); - - b.Property("Inn") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("LastOperation") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Locality") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("OwnerType") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Region") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("RegistrationRegion") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Street") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("To") - .HasColumnType("INTEGER"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleOwnershipPeriod"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Brand") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Model") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Url") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("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 - } - } -} diff --git a/AutoCatCore/Migrations/20240508141817_InitialCreate.cs b/AutoCatCore/Migrations/20240508141817_InitialCreate.cs deleted file mode 100644 index 0bb83de..0000000 --- a/AutoCatCore/Migrations/20240508141817_InitialCreate.cs +++ /dev/null @@ -1,351 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AutoCatCore.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Email = table.Column(type: "TEXT", maxLength: 50, nullable: false), - Token = table.Column(type: "TEXT", maxLength: 300, nullable: true), - FirebaseIdToken = table.Column(type: "TEXT", maxLength: 300, nullable: true), - FirebaseRefreshToken = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Number = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Volume = table.Column(type: "INTEGER", nullable: true), - PowerKw = table.Column(type: "REAL", nullable: true), - PowerHp = table.Column(type: "REAL", nullable: true), - FuelType = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Original = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Normalized = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - NameId = table.Column(type: "INTEGER", nullable: true), - Logo = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - NameId = table.Column(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(type: "TEXT", maxLength: 10, nullable: false), - CurrentNumber = table.Column(type: "TEXT", maxLength: 10, nullable: true), - Vin1 = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Vin2 = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Sts = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Pts = table.Column(type: "TEXT", maxLength: 50, nullable: true), - BrandId = table.Column(type: "INTEGER", nullable: true), - ModelId = table.Column(type: "INTEGER", nullable: true), - Color = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Year = table.Column(type: "INTEGER", nullable: true), - Category = table.Column(type: "TEXT", maxLength: 100, nullable: true), - IsRightWheel = table.Column(type: "INTEGER", nullable: true), - IsJapanese = table.Column(type: "INTEGER", nullable: true), - AddedDate = table.Column(type: "REAL", nullable: true), - UpdatedDate = table.Column(type: "REAL", nullable: true), - AddedBy = table.Column(type: "TEXT", maxLength: 100, nullable: true), - EngineId = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Number = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Date = table.Column(type: "REAL", nullable: true), - Vin = table.Column(type: "TEXT", maxLength: 50, nullable: true), - PlateNumber = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Name = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Status = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Restrictions = table.Column(type: "TEXT", maxLength: 500, nullable: true), - Insurant = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Owner = table.Column(type: "TEXT", maxLength: 100, nullable: true), - UsageRegion = table.Column(type: "TEXT", maxLength: 100, nullable: true), - VehicleNumber = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Url = table.Column(type: "TEXT", maxLength: 200, nullable: true), - Price = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Date = table.Column(type: "REAL", maxLength: 50, nullable: true), - Mileage = table.Column(type: "TEXT", maxLength: 50, nullable: true), - Region = table.Column(type: "TEXT", maxLength: 100, nullable: true), - City = table.Column(type: "TEXT", maxLength: 100, nullable: true), - AdDescription = table.Column(type: "TEXT", maxLength: 500, nullable: true), - Photos = table.Column(type: "TEXT", nullable: true), - VehicleNumber = table.Column(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(type: "TEXT", nullable: false), - Date = table.Column(type: "REAL", nullable: true), - Latitude = table.Column(type: "REAL", nullable: true), - Longitude = table.Column(type: "REAL", nullable: true), - Address = table.Column(type: "TEXT", maxLength: 100, nullable: true), - VehicleNumber = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - LastOperation = table.Column(type: "TEXT", maxLength: 500, nullable: true), - OwnerType = table.Column(type: "TEXT", maxLength: 100, nullable: true), - From = table.Column(type: "INTEGER", nullable: true), - To = table.Column(type: "INTEGER", nullable: true), - Region = table.Column(type: "TEXT", maxLength: 300, nullable: true), - RegistrationRegion = table.Column(type: "TEXT", maxLength: 300, nullable: true), - Locality = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Code = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Street = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Building = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Inn = table.Column(type: "TEXT", maxLength: 100, nullable: true), - VehicleNumber = table.Column(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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Brand = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Model = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Date = table.Column(type: "REAL", nullable: true), - Url = table.Column(type: "TEXT", maxLength: 500, nullable: true), - VehicleNumber = table.Column(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"); - } - - /// - 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"); - } - } -} diff --git a/AutoCatCore/Migrations/AutoCatDbContextModelSnapshot.cs b/AutoCatCore/Migrations/AutoCatDbContextModelSnapshot.cs deleted file mode 100644 index 57004dc..0000000 --- a/AutoCatCore/Migrations/AutoCatDbContextModelSnapshot.cs +++ /dev/null @@ -1,507 +0,0 @@ -// -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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Insurant") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Name") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Number") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Owner") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("PlateNumber") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Restrictions") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Status") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("UsageRegion") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.Property("Vin") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("Osago"); - }); - - modelBuilder.Entity("AutoCatCore.Model.User", b => - { - b.Property("Email") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("FirebaseIdToken") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("FirebaseRefreshToken") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Token") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.HasKey("Email"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("AutoCatCore.Model.Vehicle", b => - { - b.Property("Number") - .HasMaxLength(10) - .HasColumnType("TEXT"); - - b.Property("AddedBy") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("AddedDate") - .HasColumnType("REAL"); - - b.Property("BrandId") - .HasColumnType("INTEGER"); - - b.Property("Category") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Color") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("CurrentNumber") - .HasMaxLength(10) - .HasColumnType("TEXT"); - - b.Property("EngineId") - .HasColumnType("INTEGER"); - - b.Property("IsJapanese") - .HasColumnType("INTEGER"); - - b.Property("IsRightWheel") - .HasColumnType("INTEGER"); - - b.Property("ModelId") - .HasColumnType("INTEGER"); - - b.Property("Pts") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Sts") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("UpdatedDate") - .HasColumnType("REAL"); - - b.Property("Vin1") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Vin2") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AdDescription") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("City") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasMaxLength(50) - .HasColumnType("REAL"); - - b.Property("Mileage") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Photos") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Region") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Url") - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleAd"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleBrand", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Logo") - .HasMaxLength(200) - .HasColumnType("TEXT"); - - b.Property("NameId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("NameId"); - - b.ToTable("VehicleBrand"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleEngine", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FuelType") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Number") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("PowerHp") - .HasColumnType("REAL"); - - b.Property("PowerKw") - .HasColumnType("REAL"); - - b.Property("Volume") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.ToTable("VehicleEngine"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleEvent", b => - { - b.Property("Id") - .HasColumnType("TEXT"); - - b.Property("Address") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleEvent"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleModel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("NameId") - .HasColumnType("INTEGER"); - - b.HasKey("Id"); - - b.HasIndex("NameId"); - - b.ToTable("VehicleModel"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleName", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Normalized") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Original") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("VehicleName"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehicleOwnershipPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Building") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Code") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("From") - .HasColumnType("INTEGER"); - - b.Property("Inn") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("LastOperation") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("Locality") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("OwnerType") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Region") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("RegistrationRegion") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Street") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("To") - .HasColumnType("INTEGER"); - - b.Property("VehicleNumber") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("VehicleNumber"); - - b.ToTable("VehicleOwnershipPeriod"); - }); - - modelBuilder.Entity("AutoCatCore.Model.VehiclePhoto", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Brand") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Date") - .HasColumnType("REAL"); - - b.Property("Model") - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Url") - .HasMaxLength(500) - .HasColumnType("TEXT"); - - b.Property("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 - } - } -} diff --git a/AutoCatCore/Model/AutoCatDbContext.cs b/AutoCatCore/Model/AutoCatDbContext.cs deleted file mode 100644 index cdeca7c..0000000 --- a/AutoCatCore/Model/AutoCatDbContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace AutoCatCore.Model -{ - class AutoCatDbContext: DbContext - { - public DbSet Users { get; private set; } - - public DbSet Vehicles { get; private set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlite("filename=autocat.db"); - } - } -} diff --git a/AutoCatCore/Model/Osago.cs b/AutoCatCore/Model/Osago.cs index 0786ab0..d46b6a7 100644 --- a/AutoCatCore/Model/Osago.cs +++ b/AutoCatCore/Model/Osago.cs @@ -1,28 +1,18 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class Osago + public class Osago: EmbeddedObject { - public int Id { get; set; } - [MaxLength(50)] public string? Number { get; set; } public double? Date { get; set; } - [MaxLength(50)] public string? Vin { get; set; } - [MaxLength(50)] public string? PlateNumber { get; set; } - [MaxLength(100)] public string? Name { get; set; } - [MaxLength(100)] public string? Status { get; set; } - [MaxLength(500)] public string? Restrictions { get; set; } - [MaxLength(100)] public string? Insurant { get; set; } - [MaxLength(100)] public string? Owner { get; set; } - [MaxLength(100)] public string? UsageRegion { get; set; } } } diff --git a/AutoCatCore/Model/User.cs b/AutoCatCore/Model/User.cs index 2f1dc74..51855d0 100644 --- a/AutoCatCore/Model/User.cs +++ b/AutoCatCore/Model/User.cs @@ -1,23 +1,18 @@ -using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; +using Realms; namespace AutoCatCore.Model { - public class User(string email, string token) + public class User: RealmObject { - [Key] - [MaxLength(50)] - public string Email { get; init; } = email; - - [MaxLength(300)] - public string? Token { get; init; } = token; + public string Email { get; set; } = ""; + + public string? Token { get; set; } = null; [JsonIgnore] - [MaxLength(300)] public string? FirebaseIdToken { get; init; } [JsonIgnore] - [MaxLength(300)] public string? FirebaseRefreshToken { get; init; } } } diff --git a/AutoCatCore/Model/Vehicle.cs b/AutoCatCore/Model/Vehicle.cs index 42f64e0..9927b9a 100644 --- a/AutoCatCore/Model/Vehicle.cs +++ b/AutoCatCore/Model/Vehicle.cs @@ -1,55 +1,33 @@ -using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Realms; namespace AutoCatCore.Model { - public class Vehicle(string number) + [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] + public class Vehicle: RealmObject { - [Key] [MaxLength(10)] - public string Number { get; set; } = number; - - [MaxLength(10)] + [PrimaryKey] + public string Number { get; set; } = ""; public string? CurrentNumber { get; set; } - - [MaxLength(50)] public string? Vin1 { get; set; } - - [MaxLength(50)] public string? Vin2 { 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? IsJapanese { get; set; } - public double? AddedDate { get; set; } - public double? UpdatedDate { get; set; } - - [MaxLength(100)] public string? AddedBy { get; set; } - public VehicleEngine? Engine { get; set; } - public List? Photos { get; set; } - public List? Events { get; set; } - public List? OsagoContracts { get; set; } - public List? OwnershipPeriods { get; set; } - public List? Ads { get; set; } + public IList? Photos { get; } + public IList? Events { get; } + public IList? OsagoContracts { get; } + public IList? OwnershipPeriods { get; } + public IList? Ads { get; } } } diff --git a/AutoCatCore/Model/VehicleAd.cs b/AutoCatCore/Model/VehicleAd.cs index ea2df11..f379676 100644 --- a/AutoCatCore/Model/VehicleAd.cs +++ b/AutoCatCore/Model/VehicleAd.cs @@ -1,24 +1,18 @@ -using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Realms; namespace AutoCatCore.Model { - public class VehicleAd + [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] + public class VehicleAd: EmbeddedObject { - public int Id { get; set; } - [MaxLength(200)] public string? Url { get; set; } - [MaxLength(50)] public string? Price { get; set; } - [MaxLength(50)] public double? Date { get; set; } - [MaxLength(50)] 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? Photos { get; set; } + public IList? Photos { get; } } } diff --git a/AutoCatCore/Model/VehicleBrand.cs b/AutoCatCore/Model/VehicleBrand.cs index 37602ca..e6a0498 100644 --- a/AutoCatCore/Model/VehicleBrand.cs +++ b/AutoCatCore/Model/VehicleBrand.cs @@ -1,14 +1,10 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class VehicleBrand + public class VehicleBrand: EmbeddedObject { - public int Id { get; set; } - public VehicleName? Name { get; set; } - - [MaxLength(200)] public string? Logo { get; set; } } } diff --git a/AutoCatCore/Model/VehicleEngine.cs b/AutoCatCore/Model/VehicleEngine.cs index 53eb2b7..b778665 100644 --- a/AutoCatCore/Model/VehicleEngine.cs +++ b/AutoCatCore/Model/VehicleEngine.cs @@ -1,21 +1,13 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class VehicleEngine + public class VehicleEngine: EmbeddedObject { - public int Id { get; set; } - - [MaxLength(100)] public string? Number { get; set; } - public int? Volume { get; set; } - public double? PowerKw { get; set; } - public double? PowerHp { get; set; } - - [MaxLength(100)] public string? FuelType { get; set; } } } diff --git a/AutoCatCore/Model/VehicleEvent.cs b/AutoCatCore/Model/VehicleEvent.cs index 0377289..2770be5 100644 --- a/AutoCatCore/Model/VehicleEvent.cs +++ b/AutoCatCore/Model/VehicleEvent.cs @@ -1,19 +1,13 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class VehicleEvent(string id) + public class VehicleEvent: EmbeddedObject { - [MaxLength(50)] - public string Id { get; set; } = id; - + public string Id { get; set; } = ""; public double? Date { get; set; } - public double? Latitude { get; set; } - public double? Longitude { get; set; } - - [MaxLength(100)] public string? Address { get; set; } } } diff --git a/AutoCatCore/Model/VehicleModel.cs b/AutoCatCore/Model/VehicleModel.cs index 8b2e9ec..b58a672 100644 --- a/AutoCatCore/Model/VehicleModel.cs +++ b/AutoCatCore/Model/VehicleModel.cs @@ -1,8 +1,9 @@ -namespace AutoCatCore.Model +using Realms; + +namespace AutoCatCore.Model { - public class VehicleModel + public class VehicleModel: EmbeddedObject { - public int Id { get; set; } public VehicleName? Name { get; set; } } } diff --git a/AutoCatCore/Model/VehicleName.cs b/AutoCatCore/Model/VehicleName.cs index 1f00a9d..2372093 100644 --- a/AutoCatCore/Model/VehicleName.cs +++ b/AutoCatCore/Model/VehicleName.cs @@ -1,16 +1,10 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; +using Realms; namespace AutoCatCore.Model { - public class VehicleName + public class VehicleName: EmbeddedObject { - public int Id { get; set; } - - [MaxLength(100)] public string? Original { get; set; } - - [MaxLength(100)] public string? Normalized { get; set; } } } diff --git a/AutoCatCore/Model/VehicleOwnershipPeriod.cs b/AutoCatCore/Model/VehicleOwnershipPeriod.cs index 50acf88..715f79c 100644 --- a/AutoCatCore/Model/VehicleOwnershipPeriod.cs +++ b/AutoCatCore/Model/VehicleOwnershipPeriod.cs @@ -1,40 +1,19 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class VehicleOwnershipPeriod + public class VehicleOwnershipPeriod: EmbeddedObject { - public int Id { get; set; } - - [MaxLength(500)] public string? LastOperation { get; set; } - - [MaxLength(100)] public string? OwnerType { get; set; } - public long? From { get; set; } - public long? To { 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; } } } diff --git a/AutoCatCore/Model/VehiclePhoto.cs b/AutoCatCore/Model/VehiclePhoto.cs index 81a85c7..10de5b4 100644 --- a/AutoCatCore/Model/VehiclePhoto.cs +++ b/AutoCatCore/Model/VehiclePhoto.cs @@ -1,20 +1,12 @@ -using System.ComponentModel.DataAnnotations; +using Realms; namespace AutoCatCore.Model { - public class VehiclePhoto + public class VehiclePhoto: EmbeddedObject { - public int Id { get; set; } - - [MaxLength(100)] public string? Brand { get; set; } - - [MaxLength(100)] public string? Model { get; set; } - public double? Date { get; set; } - - [MaxLength(500)] public string? Url { get; set; } } } diff --git a/AutoCatCore/Services/Api/ApiService.cs b/AutoCatCore/Services/Api/ApiService.cs index 47f4338..f9d097c 100644 --- a/AutoCatCore/Services/Api/ApiService.cs +++ b/AutoCatCore/Services/Api/ApiService.cs @@ -1,5 +1,4 @@ using System.Net.Http.Json; -using System.Text; using System.Text.Json; using AutoCatCore.Model; using AutoCatCore.Model.Requests; diff --git a/AutoCatCore/Services/Storage/IStorageService.cs b/AutoCatCore/Services/Storage/IStorageService.cs index 60d9895..c073d64 100644 --- a/AutoCatCore/Services/Storage/IStorageService.cs +++ b/AutoCatCore/Services/Storage/IStorageService.cs @@ -1,7 +1,4 @@ -using System.Collections.ObjectModel; -using System.Collections.Specialized; using AutoCatCore.Model; -using Microsoft.EntityFrameworkCore.ChangeTracking; namespace AutoCatCore.Services.Storage; @@ -15,5 +12,5 @@ public interface IStorageService public Task AddVehicle(Vehicle vehicle); - public ObservableCollection GetVehicles(); + public IEnumerable AllVehicles { get; } } \ No newline at end of file diff --git a/AutoCatCore/Services/Storage/StorageService.cs b/AutoCatCore/Services/Storage/StorageService.cs index c7461db..384dd6d 100644 --- a/AutoCatCore/Services/Storage/StorageService.cs +++ b/AutoCatCore/Services/Storage/StorageService.cs @@ -1,50 +1,39 @@ -using System.Collections.ObjectModel; -using System.Collections.Specialized; using AutoCatCore.Model; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.ChangeTracking; +using Realms; namespace AutoCatCore.Services.Storage; public class StorageService: IStorageService { - private readonly AutoCatDbContext _dbContext; + private readonly Realm _realm = Realm.GetInstance(); public bool IsLoggedIn { get { - if (_dbContext.Users.Any()) - return _dbContext.Users.First().Token != null; - else - return false; + var user = _realm.All().FirstOrDefault(); + return user?.Token != null; } } - public string? AuthToken => _dbContext.Users.Any() ? _dbContext.Users.First().Token : null; + public string? AuthToken => _realm.All().FirstOrDefault()?.Token; - public StorageService() - { - _dbContext = new AutoCatDbContext(); - _dbContext.Database.EnsureCreated(); - } - public async Task SetUser(User user) { - await _dbContext.Users.ExecuteDeleteAsync(); - await _dbContext.Users.AddAsync(user); - await _dbContext.SaveChangesAsync(); + await _realm.WriteAsync(() => + { + _realm.RemoveAll(); + _realm.Add(user); + }); } public async Task AddVehicle(Vehicle vehicle) { - await _dbContext.Vehicles.AddAsync(vehicle); - await _dbContext.SaveChangesAsync(); + await _realm.WriteAsync(() => + { + _realm.Add(vehicle); + }); } - public ObservableCollection GetVehicles() - { - _dbContext.Vehicles.Load(); - return _dbContext.Vehicles.Local.ToObservableCollection(); - } + public IEnumerable AllVehicles => _realm.All(); } \ No newline at end of file diff --git a/AutoCatCore/autocat.db b/AutoCatCore/autocat.db deleted file mode 100644 index 78d13d8..0000000 Binary files a/AutoCatCore/autocat.db and /dev/null differ