From 538000e2578e585ca8e3689e4aae94645f141746 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Mon, 25 Mar 2024 21:16:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 12 +- .../Implements/ShopStorage.cs | 153 ++++++++++++++++++ ... 20240325165319_InitialCreate.Designer.cs} | 81 +++++++++- ...ate.cs => 20240325165319_InitialCreate.cs} | 59 +++++++ .../RepairsShopDatabaseModelSnapshot.cs | 79 +++++++++ .../Models/Repair.cs | 2 + .../Models/Shop.cs | 111 +++++++++++++ .../Models/ShopRepair.cs | 22 +++ .../RepairsShopDatabase.cs | 4 +- 9 files changed, 514 insertions(+), 9 deletions(-) create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Implements/ShopStorage.cs rename CarRepairShop/CarRepairShopDatabaseImplement/Migrations/{20240324163100_InitialCreate.Designer.cs => 20240325165319_InitialCreate.Designer.cs} (67%) rename CarRepairShop/CarRepairShopDatabaseImplement/Migrations/{20240324163100_InitialCreate.cs => 20240325165319_InitialCreate.cs} (66%) create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Models/Shop.cs create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Models/ShopRepair.cs diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs index f6fc350..9e47c2e 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/OrderStorage.cs @@ -23,7 +23,7 @@ namespace CarRepairShopDatabaseImplement.Implements return new(); } using var context = new RepairsShopDatabase(); - return context.Orders + return context.Orders.Include (x => x.Repair) .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); @@ -35,12 +35,12 @@ namespace CarRepairShopDatabaseImplement.Implements return null; } using var context = new RepairsShopDatabase(); - return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + return context.Orders.Include(x => x.Repair).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } public OrderViewModel? Insert(OrderBindingModel model) { using var context = new RepairsShopDatabase(); - var newOrder = Order.Create(context, model); + var newOrder = Order.Create(model); if (newOrder == null) { return null; @@ -52,8 +52,7 @@ namespace CarRepairShopDatabaseImplement.Implements public OrderViewModel? Update(OrderBindingModel model) { using var context = new RepairsShopDatabase(); - var order = context.Orders.FirstOrDefault(x => x.Id == - model.Id); + var order = context.Orders.Include(x => x.Repair).FirstOrDefault(x => x.Id == model.Id); if (order == null) { return null; @@ -65,8 +64,7 @@ namespace CarRepairShopDatabaseImplement.Implements public OrderViewModel? Delete(OrderBindingModel model) { using var context = new RepairsShopDatabase(); - var element = context.Orders.FirstOrDefault(rec => rec.Id == - model.Id); + var element = context.Orders.Include(x => x.Repair).FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Orders.Remove(element); diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Implements/ShopStorage.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..df9821b --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Implements/ShopStorage.cs @@ -0,0 +1,153 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.StoragesContracts; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDatabaseImplement.Models; +using CarRepairShopDataModels.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarRepairShopDatabaseImplement.Implements +{ + public class ShopStorage : IShopStorage + { + public ShopViewModel? Delete(ShopBindingModel model) + { + using var context = new RepairsShopDatabase(); + var element = context.Shops.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + context.Shops.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + { + return null; + } + using var context = new RepairsShopDatabase(); + return context.Shops + .Include(x => x.Repairs) + .ThenInclude(x => x.Repair) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.Name)) + { + return new(); + } + using var context = new RepairsShopDatabase(); + return context.Shops + .Include(x => x.Repairs) + .ThenInclude(x => x.Repair) + .Select(x => x.GetViewModel) + .Where(x => x.ShopName.Contains(model.Name ?? string.Empty)) + .ToList(); + } + + public List GetFullList() + { + using var context = new RepairsShopDatabase(); + return context.Shops + .Include(x => x.Repairs) + .ThenInclude(x => x.Repair) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + using var context = new RepairsShopDatabase(); + try + { + var newShop = Shop.Create(context, model); + if (newShop == null) + { + return null; + } + if (context.Shops.Any(x => x.ShopName == newShop.ShopName)) + { + throw new Exception("Не должно быть два магазина с одним названием"); + } + context.Shops.Add(newShop); + context.SaveChanges(); + return newShop.GetViewModel; + } + catch + { + throw; + } + } + + public ShopViewModel? Update(ShopBindingModel model) + { + using var context = new RepairsShopDatabase(); + var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id); + if (shop == null) + { + return null; + } + try + { + if (context.Shops.Any(x => (x.ShopName == model.ShopName && x.Id != model.Id))) + { + throw new Exception("Не должно быть два магазина с одним названием"); + } + shop.Update(model); + shop.UpdateRepairs(context, model); + context.SaveChanges(); + return shop.GetViewModel; + } + catch + { + throw; + } + } + public bool SellRepairs(IRepairModel model, int count) + { + if (model == null) + return false; + using var context = new RepairsShopDatabase(); + using var transaction = context.Database.BeginTransaction(); + List lst = new List(); + foreach (var el in context.ShopRepairs.Where(x => x.RepairId == model.Id)) + { + int dif = count; + if (el.Count < dif) + dif = el.Count; + el.Count -= dif; + count -= dif; + if (el.Count == 0) + { + lst.Add(el); + } + if (count == 0) + break; + } + if (count > 0) + { + transaction.Rollback(); + return false; + } + foreach (var el in lst) + { + context.ShopRepairs.Remove(el); + } + context.SaveChanges(); + transaction.Commit(); + return true; + } + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.Designer.cs similarity index 67% rename from CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs rename to CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.Designer.cs index b8e7c4d..a43096b 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.Designer.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace CarRepairShopDatabaseImplement.Migrations { [DbContext(typeof(RepairsShopDatabase))] - [Migration("20240324163100_InitialCreate")] + [Migration("20240325165319_InitialCreate")] partial class InitialCreate { /// @@ -124,6 +124,59 @@ namespace CarRepairShopDatabaseImplement.Migrations b.ToTable("RepairComponents"); }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCapacity") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.ShopRepair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RepairId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopRepairs"); + }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => { b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") @@ -154,6 +207,25 @@ namespace CarRepairShopDatabaseImplement.Migrations b.Navigation("Repair"); }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.ShopRepair", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("ShopRepairs") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Repairs") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Repair"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => { b.Navigation("RepairComponents"); @@ -164,6 +236,13 @@ namespace CarRepairShopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopRepairs"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Repairs"); }); #pragma warning restore 612, 618 } diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.cs similarity index 66% rename from CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.cs rename to CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.cs index fe70c1e..b0dad02 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240324163100_InitialCreate.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240325165319_InitialCreate.cs @@ -39,6 +39,22 @@ namespace CarRepairShopDatabaseImplement.Migrations table.PrimaryKey("PK_Repairs", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Shops", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShopName = table.Column(type: "nvarchar(max)", nullable: false), + Address = table.Column(type: "nvarchar(max)", nullable: false), + DateOpen = table.Column(type: "datetime2", nullable: false), + MaxCapacity = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shops", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Orders", columns: table => new @@ -90,6 +106,33 @@ namespace CarRepairShopDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "ShopRepairs", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RepairId = table.Column(type: "int", nullable: false), + ShopId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopRepairs", x => x.Id); + table.ForeignKey( + name: "FK_ShopRepairs_Repairs_RepairId", + column: x => x.RepairId, + principalTable: "Repairs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopRepairs_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_Orders_RepairId", table: "Orders", @@ -104,6 +147,16 @@ namespace CarRepairShopDatabaseImplement.Migrations name: "IX_RepairComponents_RepairId", table: "RepairComponents", column: "RepairId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopRepairs_RepairId", + table: "ShopRepairs", + column: "RepairId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopRepairs_ShopId", + table: "ShopRepairs", + column: "ShopId"); } /// @@ -115,11 +168,17 @@ namespace CarRepairShopDatabaseImplement.Migrations migrationBuilder.DropTable( name: "RepairComponents"); + migrationBuilder.DropTable( + name: "ShopRepairs"); + migrationBuilder.DropTable( name: "Components"); migrationBuilder.DropTable( name: "Repairs"); + + migrationBuilder.DropTable( + name: "Shops"); } } } diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs index e88cd6a..c81622a 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs @@ -121,6 +121,59 @@ namespace CarRepairShopDatabaseImplement.Migrations b.ToTable("RepairComponents"); }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("MaxCapacity") + .HasColumnType("int"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.ShopRepair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RepairId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopRepairs"); + }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => { b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") @@ -151,6 +204,25 @@ namespace CarRepairShopDatabaseImplement.Migrations b.Navigation("Repair"); }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.ShopRepair", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("ShopRepairs") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Repairs") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Repair"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => { b.Navigation("RepairComponents"); @@ -161,6 +233,13 @@ namespace CarRepairShopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopRepairs"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Repairs"); }); #pragma warning restore 612, 618 } diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Repair.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Repair.cs index e979943..022fc21 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Repair.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Repair.cs @@ -32,6 +32,8 @@ namespace CarRepairShopDatabaseImplement.Models public virtual List Components { get; set; } = new(); [ForeignKey("RepairId")] public virtual List Orders { get; set; } = new(); + [ForeignKey("RepairId")] + public virtual List ShopRepairs { get; set; } = new(); public static Repair Create(RepairsShopDatabase context, RepairBindingModel model) { return new Repair() diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Shop.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Shop.cs new file mode 100644 index 0000000..8ed8e30 --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Shop.cs @@ -0,0 +1,111 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using CarRepairShopDataModels.Models; + +namespace CarRepairShopDatabaseImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + [Required] + public string ShopName { get; private set; } + [Required] + public string Address { get; private set; } + [Required] + public DateTime DateOpen { get; private set; } + [Required] + public int MaxCapacity { get; private set; } + private Dictionary? _shopRepairs = + null; + [NotMapped] + public Dictionary ShopRepairs + { + get + { + if (_shopRepairs == null) + { + _shopRepairs = Repairs + .ToDictionary(x => x.RepairId, x => + (x.Repair as IRepairModel, x.Count)); + } + return _shopRepairs; + } + } + [ForeignKey("ShopId")] + public virtual List Repairs { get; set; } = new(); + public static Shop? Create(RepairsShopDatabase context, ShopBindingModel model) + { + if (model == null) + return null; + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + DateOpen = model.DateOpen, + MaxCapacity = model.MaxCapacity, + Repairs = model.ShopRepairs.Select(x => new ShopRepair + { + Repair = context.Repairs.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList() + }; + } + + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + DateOpen = model.DateOpen; + MaxCapacity = model.MaxCapacity; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + DateOpen = DateOpen, + ShopRepairs = ShopRepairs, + MaxCapacity = MaxCapacity + }; + + public void UpdateRepairs(RepairsShopDatabase context, ShopBindingModel model) + { + var shopRepairs = context.ShopRepairs.Where(rec => + rec.ShopId == model.Id).ToList(); + if (shopRepairs != null && shopRepairs.Count > 0) + { + context.ShopRepairs.RemoveRange(shopRepairs.Where(rec => !model.ShopRepairs.ContainsKey(rec.ShopId))); + + context.SaveChanges(); + foreach (var updateRepair in shopRepairs) + { + updateRepair.Count = + model.ShopRepairs[updateRepair.RepairId].Item2; + model.ShopRepairs.Remove(updateRepair.RepairId); + } + context.SaveChanges(); + } + var shop = context.Shops.First(x => x.Id == Id); + foreach (var pc in model.ShopRepairs) + { + context.ShopRepairs.Add(new ShopRepair + { + Shop = shop, + Repair = context.Repairs.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _shopRepairs = null; + } + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Models/ShopRepair.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Models/ShopRepair.cs new file mode 100644 index 0000000..c11c849 --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Models/ShopRepair.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarRepairShopDatabaseImplement.Models +{ + public class ShopRepair + { + public int Id { get; set; } + [Required] + public int RepairId { get; set; } + [Required] + public int ShopId { get; set; } + [Required] + public int Count { get; set; } + public virtual Shop Shop { get; set; } = new(); + public virtual Repair Repair { get; set; } = new(); + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/RepairsShopDatabase.cs b/CarRepairShop/CarRepairShopDatabaseImplement/RepairsShopDatabase.cs index 089eea5..a55d844 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/RepairsShopDatabase.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/RepairsShopDatabase.cs @@ -9,7 +9,7 @@ namespace CarRepairShopDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=RepairsShopDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True" + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=RepairsShopDataBaseHard;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True" ); } base.OnConfiguring(optionsBuilder); @@ -18,5 +18,7 @@ namespace CarRepairShopDatabaseImplement public virtual DbSet Repairs { set; get; } public virtual DbSet RepairComponents { set; get; } public virtual DbSet Orders { set; get; } + public virtual DbSet Shops { set; get; } + public virtual DbSet ShopRepairs { set; get; } } }