From 7949f9dbd6d34595291356eff4f6e48263eb3287 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 18 Mar 2024 19:22:56 +0400 Subject: [PATCH] Ready --- .../IceCreamShopDataBase.cs | 2 + .../Implements/OrderStorage.cs | 8 +- .../Implements/ShopStorage.cs | 153 ++++++++++++++++++ ... 20240318151414_InitialCreate.Designer.cs} | 81 +++++++++- ...ate.cs => 20240318151414_InitialCreate.cs} | 59 +++++++ .../IceCreamShopDataBaseModelSnapshot.cs | 79 +++++++++ .../Models/IceCream.cs | 4 +- .../Models/Shop.cs | 118 ++++++++++++++ .../Models/ShopIceCream.cs | 22 +++ 9 files changed, 520 insertions(+), 6 deletions(-) create mode 100644 IceCreamShop/IceCreamShopDatabaseImplement/Implements/ShopStorage.cs rename IceCreamShop/IceCreamShopDatabaseImplement/Migrations/{20240318125446_InitialCreate.Designer.cs => 20240318151414_InitialCreate.Designer.cs} (67%) rename IceCreamShop/IceCreamShopDatabaseImplement/Migrations/{20240318125446_InitialCreate.cs => 20240318151414_InitialCreate.cs} (66%) create mode 100644 IceCreamShop/IceCreamShopDatabaseImplement/Models/Shop.cs create mode 100644 IceCreamShop/IceCreamShopDatabaseImplement/Models/ShopIceCream.cs diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/IceCreamShopDataBase.cs b/IceCreamShop/IceCreamShopDatabaseImplement/IceCreamShopDataBase.cs index 6b30208..980fa74 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/IceCreamShopDataBase.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/IceCreamShopDataBase.cs @@ -24,6 +24,8 @@ optionsBuilder) public virtual DbSet IceCreams { set; get; } public virtual DbSet IceCreamComponents { set; get; } public virtual DbSet Orders { set; get; } + public virtual DbSet Shops { set; get; } + public virtual DbSet ShopIceCreams { set; get; } } } diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs index 450324f..5502922 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/OrderStorage.cs @@ -28,7 +28,7 @@ namespace IceCreamShopDatabaseImplement.Implements return new(); } using var context = new IceCreamShopDataBase(); - return context.Orders + return context.Orders.Include(x => x.IceCream) .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); @@ -40,7 +40,7 @@ namespace IceCreamShopDatabaseImplement.Implements return null; } using var context = new IceCreamShopDataBase(); - return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + return context.Orders.Include(x => x.IceCream).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } public OrderViewModel? Insert(OrderBindingModel model) { @@ -57,7 +57,7 @@ namespace IceCreamShopDatabaseImplement.Implements public OrderViewModel? Update(OrderBindingModel model) { using var context = new IceCreamShopDataBase(); - var order = context.Orders.FirstOrDefault(x => x.Id == + var order = context.Orders.Include(x => x.IceCream).FirstOrDefault(x => x.Id == model.Id); if (order == null) { @@ -70,7 +70,7 @@ namespace IceCreamShopDatabaseImplement.Implements public OrderViewModel? Delete(OrderBindingModel model) { using var context = new IceCreamShopDataBase(); - var element = context.Orders.FirstOrDefault(rec => rec.Id == + var element = context.Orders.Include(x => x.IceCream).FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Implements/ShopStorage.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..d9054e8 --- /dev/null +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Implements/ShopStorage.cs @@ -0,0 +1,153 @@ +using IceCreamShopContracts.BindingModels; +using IceCreamShopContracts.SearchModels; +using IceCreamShopContracts.StoragesContracts; +using IceCreamShopContracts.ViewModels; +using IceCreamShopDatabaseImplement.Models; +using IceCreamShopDataModels.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IceCreamShopDatabaseImplement.Implements +{ + public class ShopStorage : IShopStorage + { + public ShopViewModel? Delete(ShopBindingModel model) + { + using var context = new IceCreamShopDataBase(); + 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 IceCreamShopDataBase(); + return context.Shops + .Include(x => x.IceCreams) + .ThenInclude(x => x.IceCream) + .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 IceCreamShopDataBase(); + return context.Shops + .Include(x => x.IceCreams) + .ThenInclude(x => x.IceCream) + .Select(x => x.GetViewModel) + .Where(x => x.ShopName.Contains(model.Name ?? string.Empty)) + .ToList(); + } + + public List GetFullList() + { + using var context = new IceCreamShopDataBase(); + return context.Shops + .Include(x => x.IceCreams) + .ThenInclude(x => x.IceCream) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + using var context = new IceCreamShopDataBase(); + 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 IceCreamShopDataBase(); + 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.UpdateIceCreams(context, model); + context.SaveChanges(); + return shop.GetViewModel; + } + catch + { + throw; + } + } + public bool SellIceCreams(IIceCreamModel model, int count) + { + if (model == null) + return false; + using var context = new IceCreamShopDataBase(); + using var transaction = context.Database.BeginTransaction(); + List lst = new List(); + foreach(var el in context.ShopIceCreams.Where(x => x.IceCreamId == 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.ShopIceCreams.Remove(el); + } + context.SaveChanges(); + transaction.Commit(); + return true; + } + } +} diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.Designer.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.Designer.cs similarity index 67% rename from IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.Designer.cs rename to IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.Designer.cs index 38becf5..b1e15d4 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.Designer.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace IceCreamShopDatabaseImplement.Migrations { [DbContext(typeof(IceCreamShopDataBase))] - [Migration("20240318125446_InitialCreate")] + [Migration("20240318151414_InitialCreate")] partial class InitialCreate { /// @@ -124,6 +124,59 @@ namespace IceCreamShopDatabaseImplement.Migrations b.ToTable("Orders"); }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.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("IceCreamShopDatabaseImplement.Models.ShopIceCream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("IceCreamId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IceCreamId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopIceCreams"); + }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b => { b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component") @@ -154,6 +207,25 @@ namespace IceCreamShopDatabaseImplement.Migrations b.Navigation("IceCream"); }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIceCream", b => + { + b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream") + .WithMany("ShopIceCreams") + .HasForeignKey("IceCreamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IceCreamShopDatabaseImplement.Models.Shop", "Shop") + .WithMany("IceCreams") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IceCream"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b => { b.Navigation("IceCreamComponents"); @@ -164,6 +236,13 @@ namespace IceCreamShopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopIceCreams"); + }); + + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b => + { + b.Navigation("IceCreams"); }); #pragma warning restore 612, 618 } diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.cs similarity index 66% rename from IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.cs rename to IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.cs index ae61479..1110d17 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318125446_InitialCreate.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/20240318151414_InitialCreate.cs @@ -39,6 +39,22 @@ namespace IceCreamShopDatabaseImplement.Migrations table.PrimaryKey("PK_IceCreams", 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: "IceCreamComponents", columns: table => new @@ -90,6 +106,33 @@ namespace IceCreamShopDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "ShopIceCreams", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IceCreamId = 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_ShopIceCreams", x => x.Id); + table.ForeignKey( + name: "FK_ShopIceCreams_IceCreams_IceCreamId", + column: x => x.IceCreamId, + principalTable: "IceCreams", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopIceCreams_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_IceCreamComponents_ComponentId", table: "IceCreamComponents", @@ -104,6 +147,16 @@ namespace IceCreamShopDatabaseImplement.Migrations name: "IX_Orders_IceCreamId", table: "Orders", column: "IceCreamId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopIceCreams_IceCreamId", + table: "ShopIceCreams", + column: "IceCreamId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopIceCreams_ShopId", + table: "ShopIceCreams", + column: "ShopId"); } /// @@ -115,11 +168,17 @@ namespace IceCreamShopDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Orders"); + migrationBuilder.DropTable( + name: "ShopIceCreams"); + migrationBuilder.DropTable( name: "Components"); migrationBuilder.DropTable( name: "IceCreams"); + + migrationBuilder.DropTable( + name: "Shops"); } } } diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/IceCreamShopDataBaseModelSnapshot.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/IceCreamShopDataBaseModelSnapshot.cs index 8400a67..01924ff 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/IceCreamShopDataBaseModelSnapshot.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Migrations/IceCreamShopDataBaseModelSnapshot.cs @@ -121,6 +121,59 @@ namespace IceCreamShopDatabaseImplement.Migrations b.ToTable("Orders"); }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.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("IceCreamShopDatabaseImplement.Models.ShopIceCream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("IceCreamId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IceCreamId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopIceCreams"); + }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b => { b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component") @@ -151,6 +204,25 @@ namespace IceCreamShopDatabaseImplement.Migrations b.Navigation("IceCream"); }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIceCream", b => + { + b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream") + .WithMany("ShopIceCreams") + .HasForeignKey("IceCreamId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IceCreamShopDatabaseImplement.Models.Shop", "Shop") + .WithMany("IceCreams") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("IceCream"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b => { b.Navigation("IceCreamComponents"); @@ -161,6 +233,13 @@ namespace IceCreamShopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopIceCreams"); + }); + + modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b => + { + b.Navigation("IceCreams"); }); #pragma warning restore 612, 618 } diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Models/IceCream.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Models/IceCream.cs index f2f42c6..ccfe8fa 100644 --- a/IceCreamShop/IceCreamShopDatabaseImplement/Models/IceCream.cs +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Models/IceCream.cs @@ -38,6 +38,8 @@ namespace IceCreamShopDatabaseImplement.Models public virtual List Components { get; set; } = new(); [ForeignKey("IceCreamId")] public virtual List Orders { get; set; } = new(); + [ForeignKey("IceCreamId")] + public virtual List ShopIceCreams { get; set; } = new(); public static IceCream Create(IceCreamShopDataBase context, IceCreamBindingModel model) { @@ -71,7 +73,7 @@ namespace IceCreamShopDatabaseImplement.Models { var iceCreamComponents = context.IceCreamComponents.Where(rec => rec.IceCreamId == model.Id).ToList(); - if (iceCreamComponents != null && IceCreamComponents.Count > 0) + if (iceCreamComponents != null && iceCreamComponents.Count > 0) { context.IceCreamComponents.RemoveRange(iceCreamComponents.Where(rec => !model.IceCreamComponents.ContainsKey(rec.ComponentId))); diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Models/Shop.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Models/Shop.cs new file mode 100644 index 0000000..ae308a7 --- /dev/null +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Models/Shop.cs @@ -0,0 +1,118 @@ +using IceCreamShopContracts.BindingModels; +using IceCreamShopContracts.ViewModels; +using IceCreamShopDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IceCreamShopDatabaseImplement.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? _shopIceCreams = + null; + [NotMapped] + public Dictionary ShopIceCreams + { + get + { + if (_shopIceCreams == null) + { + _shopIceCreams = IceCreams + .ToDictionary(x => x.IceCreamId, x => + (x.IceCream as IIceCreamModel, x.Count)); + } + return _shopIceCreams; + } + } + [ForeignKey("ShopId")] + public virtual List IceCreams { get; set; } = new(); + public static Shop? Create(IceCreamShopDataBase 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, + IceCreams = model.ShopIceCreams.Select(x => new + ShopIceCream + { + IceCream = context.IceCreams.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, + ShopIceCreams = ShopIceCreams, + MaxCapacity = MaxCapacity + }; + + public void UpdateIceCreams(IceCreamShopDataBase context, + ShopBindingModel model) + { + var shopIceCreams = context.ShopIceCreams.Where(rec => + rec.ShopId == model.Id).ToList(); + if (shopIceCreams != null && shopIceCreams.Count > 0) + { + context.ShopIceCreams.RemoveRange(shopIceCreams.Where(rec +=> !model.ShopIceCreams.ContainsKey(rec.ShopId))); + + context.SaveChanges(); + foreach (var updateIceCream in shopIceCreams) + { + updateIceCream.Count = + model.ShopIceCreams[updateIceCream.IceCreamId].Item2; + model.ShopIceCreams.Remove(updateIceCream.IceCreamId); + } + context.SaveChanges(); + } + var shop = context.Shops.First(x => x.Id == Id); + foreach (var pc in model.ShopIceCreams) + { + context.ShopIceCreams.Add(new ShopIceCream + { + Shop = shop, + IceCream = context.IceCreams.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _shopIceCreams = null; + } + } +} diff --git a/IceCreamShop/IceCreamShopDatabaseImplement/Models/ShopIceCream.cs b/IceCreamShop/IceCreamShopDatabaseImplement/Models/ShopIceCream.cs new file mode 100644 index 0000000..42fbd6d --- /dev/null +++ b/IceCreamShop/IceCreamShopDatabaseImplement/Models/ShopIceCream.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 IceCreamShopDatabaseImplement.Models +{ + public class ShopIceCream + { + public int Id { get; set; } + [Required] + public int IceCreamId { get; set; } + [Required] + public int ShopId { get; set; } + [Required] + public int Count { get; set; } + public virtual Shop Shop { get; set; } = new(); + public virtual IceCream IceCream { get; set; } = new(); + } +}