using AbstractFoodOrdersDataModel.Models; using AbstractShopContracts.BindingModels; using AbstractShopContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AbstractShopListImplement.Models { public class Food : IFoodModel { public int Id { get; private set; } public string FoodName { get; private set; } = string.Empty; public double Price { get; private set; } public Dictionary FoodComponents { get; private set; } = new Dictionary(); public static Food? Create(FoodBindingModel? model) { if (model == null) { return null; } return new Food() { Id = model.Id, FoodName = model.FoodName, Price = model.Price, FoodComponents = model.FoodComponents }; } public void Update(FoodBindingModel? model) { if (model == null) { return; } FoodName = model.FoodName; Price = model.Price; FoodComponents = model.FoodComponents; } public FoodViewModel GetViewModel => new() { Id = Id, FoodName = FoodName, Price = Price, FoodComponents = FoodComponents }; } }