вроде работает

This commit is contained in:
Inohara 2023-04-09 19:24:19 +04:00
parent 1f71004c0b
commit bbc89019e5
9 changed files with 743 additions and 7 deletions

View File

@ -170,9 +170,9 @@ namespace IceCreamBusinessLogic.BusinessLogics
foreach (var shop in _shopStorage.GetFullList()) foreach (var shop in _shopStorage.GetFullList())
{ {
freeSpace += shop.IceCreamMaxCount; freeSpace += shop.IceCreamMaxCount;
foreach (var doc in shop.ShopIceCreams) foreach (var icecream in shop.ShopIceCreams)
{ {
freeSpace -= doc.Value.Item2; freeSpace -= icecream.Value.Item2;
} }
} }
@ -185,9 +185,9 @@ namespace IceCreamBusinessLogic.BusinessLogics
foreach (var shop in _shopStorage.GetFullList()) foreach (var shop in _shopStorage.GetFullList())
{ {
freeSpace = shop.IceCreamMaxCount; freeSpace = shop.IceCreamMaxCount;
foreach (var doc in shop.ShopIceCreams) foreach (var icecream in shop.ShopIceCreams)
{ {
freeSpace -= doc.Value.Item2; freeSpace -= icecream.Value.Item2;
} }
if (freeSpace == 0) if (freeSpace == 0)
{ {

View File

@ -9,7 +9,7 @@ namespace IceCreamShopDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
optionsBuilder.UseSqlServer(@"Data Source=INOSENJU\SQLEXPRESS;Initial Catalog=IceCreamShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=INOSENJU\SQLEXPRESS;Initial Catalog=IceCreamShopDatabaseHard;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }
@ -21,5 +21,8 @@ namespace IceCreamShopDatabaseImplement
public virtual DbSet<IceCreamComponent> IceCreamComponents { set; get; } public virtual DbSet<IceCreamComponent> IceCreamComponents { set; get; }
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Shop> Shops { set; get; }
public virtual DbSet<ShopIcecream> ShopIcecreams { set; get; }
} }
} }

View File

@ -0,0 +1,137 @@
using IceCreamShopContracts.BindingModels;
using IceCreamShopContracts.SearchModels;
using IceCreamShopContracts.StoragesContracts;
using IceCreamShopContracts.ViewModels;
using IceCreamShopDatabaseImplement.Models;
using AbstractIceCreamShopDataModels.Models;
using Microsoft.EntityFrameworkCore;
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 (!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<ShopViewModel> 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.Name.Contains(model.Name ?? string.Empty))
.ToList();
}
public List<ShopViewModel> GetFullList()
{
using var context = new IceCreamShopDatabase();
return context.Shops
.Include(x => x.IceCreams)
.ThenInclude(x => x.IceCream)
.Select(shop => shop.GetViewModel)
.ToList();
}
public ShopViewModel? Insert(ShopBindingModel model)
{
using var context = new IceCreamShopDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var newShop = Shop.Create(context, model);
if (newShop == null)
{
return null;
}
if (context.Shops.Any(x => x.Name == newShop.Name))
{
throw new Exception("Не должно быть два магазина с одним названием");
}
context.Shops.Add(newShop);
context.SaveChanges();
transaction.Commit();
return newShop.GetViewModel;
}
catch
{
transaction.Rollback();
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;
}
shop.Update(model);
shop.UpdatePastries(context, model);
context.SaveChanges();
return shop.GetViewModel;
}
public bool SellIceCreams(IIceCreamModel icecream, int needCount)
{
using var context = new IceCreamShopDatabase();
using var transaction = context.Database.BeginTransaction();
foreach (var sp in context.ShopIcecreams.Where(x => x.IceCreamId == icecream.Id))
{
var res = Math.Min(needCount, sp.Count);
sp.Count -= res;
needCount -= res;
if (sp.Count == 0) // Изделия больше нет в магазине, значит удаляем его
{
context.ShopIcecreams.Remove(sp);
}
if (needCount == 0) // Нельзя коммитить изменения в цикле, что использует контекст, поэтому выходим
{
break;
}
}
if (needCount == 0)
{
context.SaveChanges();
transaction.Commit();
}
else
{
transaction.Rollback();
}
return needCount == 0;
}
}
}

View File

@ -0,0 +1,264 @@
// <auto-generated />
using System;
using IceCreamShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace IceCreamShopDatabaseImplement.Migrations
{
[DbContext(typeof(IceCreamShopDatabase))]
[Migration("20230409123459_shops")]
partial class shops
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("IceCreamName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("IceCreams");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("IceCreamId");
b.ToTable("IceCreamComponents");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.Property<string>("IceCreamName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.ToTable("Orders");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Adress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("IceCreamId")
.HasColumnType("int");
b.Property<int>("IceCreamMaxCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("OpeningDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.ToTable("Shops");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIcecream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.HasIndex("ShopId");
b.ToTable("IceCreams");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component")
.WithMany("IceCreamComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany("Components")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("IceCream");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", null)
.WithMany("Orders")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", null)
.WithMany("Shops")
.HasForeignKey("IceCreamId");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIcecream", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany()
.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");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCream", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
b.Navigation("Shops");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.Navigation("IceCreams");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IceCreamShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class shops : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Shops",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
IceCreamMaxCount = table.Column<int>(type: "int", nullable: false),
IceCreamId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Shops", x => x.Id);
table.ForeignKey(
name: "FK_Shops_IceCreams_IceCreamId",
column: x => x.IceCreamId,
principalTable: "IceCreams",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "IceCreams",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
IceCreamId = table.Column<int>(type: "int", nullable: false),
ShopId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(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_ShopIcecreams_IceCreamId",
table: "IceCreams",
column: "IceCreamId");
migrationBuilder.CreateIndex(
name: "IX_ShopIcecreams_ShopId",
table: "IceCreams",
column: "ShopId");
migrationBuilder.CreateIndex(
name: "IX_Shops_IceCreamId",
table: "Shops",
column: "IceCreamId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "IceCreams");
migrationBuilder.DropTable(
name: "Shops");
migrationBuilder.DropColumn(
name: "IceCreamName",
table: "Orders");
}
}
}

View File

@ -120,11 +120,69 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("DocumentId"); b.HasIndex("IceCreamId");
b.ToTable("Orders"); b.ToTable("Orders");
}); });
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Adress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("IceCreamId")
.HasColumnType("int");
b.Property<int>("IceCreamMaxCount")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("OpeningDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.ToTable("Shops");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIcecream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("IceCreamId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("IceCreamId");
b.HasIndex("ShopId");
b.ToTable("IceCreams");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b => modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.IceCreamComponent", b =>
{ {
b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component") b.HasOne("IceCreamShopDatabaseImplement.Models.Component", "Component")
@ -144,6 +202,41 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.Navigation("IceCream"); b.Navigation("IceCream");
}); });
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", null)
.WithMany("Orders")
.HasForeignKey("IceCreamId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", null)
.WithMany("Shops")
.HasForeignKey("IceCreamId");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.ShopIcecream", b =>
{
b.HasOne("IceCreamShopDatabaseImplement.Models.IceCream", "IceCream")
.WithMany()
.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 => modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("IceCreamComponents"); b.Navigation("IceCreamComponents");
@ -154,6 +247,13 @@ namespace IceCreamShopDatabaseImplement.Migrations
b.Navigation("Components"); b.Navigation("Components");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("Shops");
});
modelBuilder.Entity("IceCreamShopDatabaseImplement.Models.Shop", b =>
{
b.Navigation("IceCreams");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -26,7 +26,8 @@ namespace IceCreamShopDatabaseImplement.Models
if (_iceCreamComponents == null) if (_iceCreamComponents == null)
{ {
_iceCreamComponents = Components _iceCreamComponents = Components
.ToDictionary(recPC => recPC.ComponentId, recPC => (recPC.Component as IComponentModel, recPC.Count)); .ToDictionary(recPC => recPC.ComponentId,
recPC => (recPC.Component as IComponentModel, recPC.Count));
} }
return _iceCreamComponents; return _iceCreamComponents;
} }
@ -37,6 +38,8 @@ namespace IceCreamShopDatabaseImplement.Models
[ForeignKey("IceCreamId")] [ForeignKey("IceCreamId")]
public virtual List<Order> Orders { get; set; } = new(); public virtual List<Order> Orders { get; set; } = new();
[ForeignKey("IceCreamId")]
public virtual List<Shop> Shops { get; set; } = new();
public static IceCream Create(IceCreamShopDatabase context, IceCreamBindingModel model) public static IceCream Create(IceCreamShopDatabase context, IceCreamBindingModel model)
{ {

View File

@ -0,0 +1,116 @@
using AbstractIceCreamShopDataModels.Models;
using IceCreamShopContracts.BindingModels;
using IceCreamShopContracts.ViewModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net;
namespace IceCreamShopDatabaseImplement.Models
{
public class Shop : IShopModel
{
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Adress { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
private Dictionary<int, (IIceCreamModel, int)>? _cashedIcecreams = null;
[NotMapped]
public Dictionary<int, (IIceCreamModel, int)> ShopIceCreams
{
get
{
if(_cashedIcecreams == null)
{
_cashedIcecreams = IceCreams.ToDictionary(recPC => recPC.IceCreamId, recPC => (recPC.IceCream as IIceCreamModel, recPC.Count));
}
return _cashedIcecreams;
}
}
[Required]
public int IceCreamMaxCount { get; private set; }
public int Id { get; private set; }
[ForeignKey("ShopId")]
public virtual List<ShopIcecream> IceCreams { get; set; } = new();
public static Shop? Create(IceCreamShopDatabase context, ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
Name = model.Name,
Adress = model.Adress,
OpeningDate = model.OpeningDate,
IceCreamMaxCount = model.IceCreamMaxCount,
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;
}
Name = model.Name;
Adress = model.Adress;
OpeningDate = model.OpeningDate;
IceCreamMaxCount = model.IceCreamMaxCount;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Adress = Adress,
ShopIceCreams = ShopIceCreams,
OpeningDate = OpeningDate,
IceCreamMaxCount = IceCreamMaxCount,
};
public void UpdatePastries(IceCreamShopDatabase context, ShopBindingModel model)
{
var iceCreams = context.ShopIcecreams.Where(rec => rec.ShopId == model.Id).ToList();
if (iceCreams != null && iceCreams.Count > 0)
{
// удалили те, которых нет в модели
context.ShopIcecreams.RemoveRange(iceCreams.Where(rec => !model.ShopIceCreams.ContainsKey(rec.IceCreamId)));
context.SaveChanges();
iceCreams = context.ShopIcecreams.Where(rec => rec.ShopId == model.Id).ToList();
// обновили количество у существующих записей
foreach (var updateIceCream in iceCreams)
{
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 elem in model.ShopIceCreams)
{
context.ShopIcecreams.Add(new ShopIcecream
{
Shop = shop,
IceCream = context.IceCreams.First(x => x.Id == elem.Key),
Count = elem.Value.Item2
});
context.SaveChanges();
}
_cashedIcecreams = null;
}
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
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();
}
}