diff --git a/BlacksmithWorkshop/BlacksmithWorkshop.sln b/BlacksmithWorkshop/BlacksmithWorkshop.sln index 0834832..9bee79b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop.sln +++ b/BlacksmithWorkshop/BlacksmithWorkshop.sln @@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopBusinessL EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopListImplement", "BlacksmithWorkshopListImplement\BlacksmithWorkshopListImplement.csproj", "{2942D468-0C3B-4B8D-A15F-184F5D7C969A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopFileImplement", "BlacksmithWorkshopFileImplement\BlacksmithWorkshopFileImplement.csproj", "{58737D93-9A12-4D07-BF3F-86AC512CE626}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopFileImplement", "BlacksmithWorkshopFileImplement\BlacksmithWorkshopFileImplement.csproj", "{58737D93-9A12-4D07-BF3F-86AC512CE626}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopDatabaseImplement", "BlacksmithWorkshopDatabaseImplement\BlacksmithWorkshopDatabaseImplement.csproj", "{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,6 +47,10 @@ Global {58737D93-9A12-4D07-BF3F-86AC512CE626}.Debug|Any CPU.Build.0 = Debug|Any CPU {58737D93-9A12-4D07-BF3F-86AC512CE626}.Release|Any CPU.ActiveCfg = Release|Any CPU {58737D93-9A12-4D07-BF3F-86AC512CE626}.Release|Any CPU.Build.0 = Release|Any CPU + {EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/BlacksmithWorkshopDatabaseImplement.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs new file mode 100644 index 0000000..fe1589b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Manufacture.cs @@ -0,0 +1,20 @@ +using BlacksmithWorkshopDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDatabaseImplement.Models +{ + internal class Manufacture : IManufactureModel + { + public string ManufactureName => throw new NotImplementedException(); + + public double Price => throw new NotImplementedException(); + + public Dictionary ManufactureWorkPieces => throw new NotImplementedException(); + + public int Id => throw new NotImplementedException(); + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/WorkPiece.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/WorkPiece.cs new file mode 100644 index 0000000..4702c6e --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/WorkPiece.cs @@ -0,0 +1,71 @@ +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.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BlacksmithWorkshopDatabaseImplement.Models +{ + public class WorkPiece : IWorkPieceModel + { + public int Id { get; private set; } + + [Required] + public string WorkPieceName { get; private set; } = string.Empty; + + [Required] + public double Cost { get; set; } + + [ForeignKey("WorkPieceId")] + public virtual List manufactureWorkPieces { get; set; } = new(); + + public static WorkPiece? Create(WorkPieceBindingModel model) + { + if(model == null) + { + return null; + } + + return new WorkPiece() + { + Id = model.Id, + WorkPieceName = model.WorkPieceName, + Cost = model.Cost + }; + } + + public static WorkPiece Create(WorkPieceViewModel model) + { + return new WorkPiece + { + Id = model.Id, + WorkPieceName = model.WorkPieceName, + Cost = model.Cost + }; + } + + public void Update(WorkPieceBindingModel model) + { + if(model == null) + { + return; + } + + WorkPieceName = model.WorkPieceName; + Cost = model.Cost; + } + + public WorkPieceViewModel GetViewModel => new() + { + Id = Id, + WorkPieceName = WorkPieceName, + Cost = Cost + }; + } +}