55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
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<int, (IComponentModel, int)> FoodComponents
|
|
{
|
|
get;
|
|
private set;
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
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
|
|
};
|
|
}
|
|
}
|