using PizzeriaContracts.BindingModels; using PizzeriaContracts.ViewModels; using PizzeriaDataModels; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PizzeriaListImplement.Models { public class Pizza : IPizzaModel { public int Id { get; private set; } public string ProductName { get; private set; } = string.Empty; public double Price { get; private set; } public Dictionary ProductComponents { get; private set; } = new Dictionary(); public static Pizza? Create(PizzaBindingModel? model) { if (model == null) { return null; } return new Pizza() { Id = model.Id, ProductName = model.ProductName, Price = model.Price, ProductComponents = model.ProductComponents }; } public void Update(PizzaBindingModel? model) { if (model == null) { return; } ProductName = model.ProductName; Price = model.Price; ProductComponents = model.ProductComponents; } public PizzaViewModel GetViewModel => new() { Id = Id, ProductName = ProductName, Price = Price, ProductComponents = ProductComponents }; } }