using DinerContracts.BindingModels; using DinerContracts.ViewModels; using DinerDataModels.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DinerListImplement.Models { internal class Snack : ISnackModel { public string ProductName { get; private set; } = String.Empty; public double Price { get; private set; } public Dictionary ProductComponents { get; private set; } = new Dictionary(); public int ID { get; private set; } public static Snack? Create(SnackBindingModel? model) { if (model == null) return null; return new Snack() { ID = model.ID, ProductName = model.ProductName, Price = model.Price, ProductComponents = model.ProductComponents }; } public void Update(SnackBindingModel? model) { if (model == null) return; ProductName = model.ProductName; Price = model.Price; ProductComponents = model.ProductComponents; } public SnackViewModel GetViewModel => new() { ID = ID, ProductName = ProductName, Price = Price, ProductComponents = ProductComponents }; } }