using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using SushiBarDataModels.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 SushiBarDatabaseImplement.Models { public class Menu : IMenuModel { public int Id { get; set; } [Required] public string FoodName { get; set; } = string.Empty; [Required] public string Description { get; set; } = string.Empty; [Required] public double Price { get; set; } [ForeignKey("MenuId")] public virtual List TaskMenus { get; set; } = new(); public static Menu? Create(MenuBindingModel model) { if (model == null) return null; return new Menu() { Id = model.Id, FoodName = model.FoodName, Description = model.Description, Price = model.Price }; } public void Update(MenuBindingModel model) { if (model == null) return; Id = model.Id; FoodName = model.FoodName; Description = model.Description; Price = model.Price; } public MenuViewModel GetViewModel => new() { Id = Id, FoodName = FoodName, Description = Description, Price = Price }; } }