diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDataBase.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDataBase.cs index c7639ab..df1a0c7 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDataBase.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDataBase.cs @@ -14,7 +14,7 @@ namespace BlacksmithWorkshopDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BlacksmithWorkshopDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BlacksmithWorkshopDataBaseHard;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } @@ -22,5 +22,7 @@ namespace BlacksmithWorkshopDatabaseImplement public virtual DbSet Manufactures { set; get; } public virtual DbSet ManufactureComponents { set; get; } public virtual DbSet Orders { set; get; } + public virtual DbSet Shops { set; get; } + public virtual DbSet ShopManufactures { set; get; } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs index f489a4e..99c81c5 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/OrderStorage.cs @@ -30,6 +30,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements } using var context = new BlacksmithWorkshopDataBase(); return context.Orders + .Include(x => x.Manufacture) .Where(x => x.Id == model.Id) .Select(x => x.GetViewModel) .ToList(); @@ -41,7 +42,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements return null; } using var context = new BlacksmithWorkshopDataBase(); - return context.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; + return context.Orders + .Include(x => x.Manufacture) + .FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } public OrderViewModel? Insert(OrderBindingModel model) { @@ -58,8 +61,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? Update(OrderBindingModel model) { using var context = new BlacksmithWorkshopDataBase(); - var order = context.Orders.FirstOrDefault(x => x.Id == - model.Id); + var order = context.Orders + .Include(x => x.Manufacture) + .FirstOrDefault(x => x.Id == model.Id); if (order == null) { return null; @@ -71,8 +75,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements public OrderViewModel? Delete(OrderBindingModel model) { using var context = new BlacksmithWorkshopDataBase(); - var element = context.Orders.FirstOrDefault(rec => rec.Id == - model.Id); + var element = context.Orders + .Include(x => x.Manufacture) + .FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Orders.Remove(element); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ShopStorage.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..9c5bf2f --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Implements/ShopStorage.cs @@ -0,0 +1,153 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.SearchModels; +using BlacksmithWorkshopContracts.StoragesContracts; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDatabaseImplement.Models; +using BlacksmithWorkshopDataModels.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDatabaseImplement.Implements +{ + public class ShopStorage : IShopStorage + { + public ShopViewModel? Delete(ShopBindingModel model) + { + using var context = new BlacksmithWorkshopDataBase(); + 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.ShopName) && !model.Id.HasValue) + { + return null; + } + using var context = new BlacksmithWorkshopDataBase(); + return context.Shops + .Include(x => x.Manufactures) + .ThenInclude(x => x.Manufacture) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName)) + { + return new(); + } + using var context = new BlacksmithWorkshopDataBase(); + return context.Shops + .Include(x => x.Manufactures) + .ThenInclude(x => x.Manufacture) + .Select(x => x.GetViewModel) + .Where(x => x.ShopName.Contains(model.ShopName ?? string.Empty)) + .ToList(); + } + + public List GetFullList() + { + using var context = new BlacksmithWorkshopDataBase(); + return context.Shops + .Include(x => x.Manufactures) + .ThenInclude(x => x.Manufacture) + .Select(x => x.GetViewModel) + .ToList(); + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + using var context = new BlacksmithWorkshopDataBase(); + 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 BlacksmithWorkshopDataBase(); + 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.UpdateManufactures(context, model); + context.SaveChanges(); + return shop.GetViewModel; + } + catch + { + throw; + } + } + public bool SellManufactures(IManufactureModel model, int count) + { + if (model == null) + return false; + using var context = new BlacksmithWorkshopDataBase(); + using var transaction = context.Database.BeginTransaction(); + List lst = new List(); + foreach (var el in context.ShopManufactures.Where(x => x.ManufactureId == 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.ShopManufactures.Remove(el); + } + context.SaveChanges(); + transaction.Commit(); + return true; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.Designer.cs similarity index 67% rename from BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.Designer.cs rename to BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.Designer.cs index 1629012..7f1e4bb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BlacksmithWorkshopDatabaseImplement.Migrations { [DbContext(typeof(BlacksmithWorkshopDataBase))] - [Migration("20240324164611_InitialCreate")] + [Migration("20240325164926_InitialCreate")] partial class InitialCreate { /// @@ -124,6 +124,59 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.ToTable("Orders"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxCapacity") + .HasColumnType("int"); + + b.Property("OpeningDate") + .HasColumnType("datetime2"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b => { b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component") @@ -154,6 +207,25 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Manufacture"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("ShopManufactures") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b => { b.Navigation("ManufactureComponents"); @@ -164,6 +236,13 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); }); #pragma warning restore 612, 618 } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.cs similarity index 66% rename from BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.cs rename to BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.cs index 7a57164..b5ebbf5 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240324164611_InitialCreate.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240325164926_InitialCreate.cs @@ -39,6 +39,22 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations table.PrimaryKey("PK_Manufactures", 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), + OpeningDate = 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: "ManufactureComponents", columns: table => new @@ -90,6 +106,33 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "ShopManufactures", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ManufactureId = 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_ShopManufactures", x => x.Id); + table.ForeignKey( + name: "FK_ShopManufactures_Manufactures_ManufactureId", + column: x => x.ManufactureId, + principalTable: "Manufactures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopManufactures_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_ManufactureComponents_ComponentId", table: "ManufactureComponents", @@ -104,6 +147,16 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations name: "IX_Orders_ManufactureId", table: "Orders", column: "ManufactureId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopManufactures_ManufactureId", + table: "ShopManufactures", + column: "ManufactureId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopManufactures_ShopId", + table: "ShopManufactures", + column: "ShopId"); } /// @@ -115,11 +168,17 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Orders"); + migrationBuilder.DropTable( + name: "ShopManufactures"); + migrationBuilder.DropTable( name: "Components"); migrationBuilder.DropTable( name: "Manufactures"); + + migrationBuilder.DropTable( + name: "Shops"); } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs index e3ce109..e0bce8b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs @@ -121,6 +121,59 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.ToTable("Orders"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxCapacity") + .HasColumnType("int"); + + b.Property("OpeningDate") + .HasColumnType("datetime2"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ManufactureId") + .HasColumnType("int"); + + b.Property("ShopId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ManufactureId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopManufactures"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b => { b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component") @@ -151,6 +204,25 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Manufacture"); }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b => + { + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture") + .WithMany("ShopManufactures") + .HasForeignKey("ManufactureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop") + .WithMany("Manufactures") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Manufacture"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b => { b.Navigation("ManufactureComponents"); @@ -161,6 +233,13 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations b.Navigation("Components"); b.Navigation("Orders"); + + b.Navigation("ShopManufactures"); + }); + + modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b => + { + b.Navigation("Manufactures"); }); #pragma warning restore 612, 618 } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs index 24f00be..6238a08 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs @@ -38,6 +38,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Models public virtual List Components { get; set; } = new(); [ForeignKey("ManufactureId")] public virtual List Orders { get; set; } = new(); + + [ForeignKey("ManufactureId")] + public virtual List ShopManufactures { get; set; } = new(); public static Manufacture Create(BlacksmithWorkshopDataBase context, ManufactureBindingModel model) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs new file mode 100644 index 0000000..cc3f118 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Shop.cs @@ -0,0 +1,115 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.ViewModels; +using BlacksmithWorkshopDataModels.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 BlacksmithWorkshopDatabaseImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + [Required] + public string ShopName { get; private set; } = string.Empty; + [Required] + public string Address { get; private set; } = string.Empty; + [Required] + public DateTime OpeningDate { get; private set; } + [Required] + public int MaxCapacity { get; private set; } + private Dictionary? _ShopManufacture = null; + [NotMapped] + public Dictionary ShopManufactures + { + get + { + if (_ShopManufacture == null) + { + _ShopManufacture = Manufactures + .ToDictionary(x => x.ManufactureId, x => + (x.Manufacture as IManufactureModel, x.Count)); + } + return _ShopManufacture; + } + } + [ForeignKey("ShopId")] + public virtual List Manufactures { get; set; } = new(); + public static Shop? Create(BlacksmithWorkshopDataBase context, ShopBindingModel model) + { + if (model == null) + return null; + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + OpeningDate = model.OpeningDate, + MaxCapacity = model.MaxCapacity, + Manufactures = model.ShopManufactures.Select(x => new ShopManufacture + { + Manufacture = context.Manufactures.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; + OpeningDate = model.OpeningDate; + MaxCapacity = model.MaxCapacity; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + OpeningDate = OpeningDate, + ShopManufactures = ShopManufactures, + MaxCapacity = MaxCapacity + }; + + public void UpdateManufactures(BlacksmithWorkshopDataBase context, ShopBindingModel model) + { + var ShopManufacture = context.ShopManufactures.Where(rec => + rec.ShopId == model.Id).ToList(); + if (ShopManufacture != null && ShopManufacture.Count > 0) + { + context.ShopManufactures.RemoveRange(ShopManufacture.Where(rec + => !model.ShopManufactures.ContainsKey(rec.ShopId))); + + context.SaveChanges(); + foreach (var updateManufacture in ShopManufacture) + { + updateManufacture.Count = + model.ShopManufactures[updateManufacture.ManufactureId].Item2; + model.ShopManufactures.Remove(updateManufacture.ManufactureId); + } + context.SaveChanges(); + } + var shop = context.Shops.First(x => x.Id == Id); + foreach (var pc in model.ShopManufactures) + { + context.ShopManufactures.Add(new ShopManufacture + { + Shop = shop, + Manufacture = context.Manufactures.First(x => x.Id == pc.Key), + Count = pc.Value.Item2 + }); + context.SaveChanges(); + } + _ShopManufacture = null; + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/ShopManufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/ShopManufacture.cs new file mode 100644 index 0000000..ff1b725 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/ShopManufacture.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 BlacksmithWorkshopDatabaseImplement.Models +{ + public class ShopManufacture + { + public int Id { get; set; } + [Required] + public int ManufactureId { get; set; } + [Required] + public int ShopId { get; set; } + [Required] + public int Count { get; set; } + public virtual Shop Shop { get; set; } = new(); + public virtual Manufacture Manufacture { get; set; } = new(); + } +}