using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace SushiBarDatabaseImplement.Models { public class Ingredient { [Key] public int Id { get; set; } [Required] public string IngredientName { get; set; } = string.Empty; [Required] public string Unit { get; set; } = string.Empty; [Required] public double Cost { get; set; } [ForeignKey("IngredientId")] public virtual List DishIngredients { get; set; } = new(); public static Ingredient? Create(IngredientBindingModel Model) { return new Ingredient() { IngredientName = Model.IngredientName, Unit = Model.Unit, Cost = Model.Cost, }; } public void Update(IngredientBindingModel Model) { Cost = Model.Cost; } public IngredientViewModel ViewModel => new() { Id = Id, IngredientName = IngredientName, Unit = Unit, Cost = Cost, }; } }