2023-01-31 15:23:18 +04:00
|
|
|
|
using SushiBarContracts.BindingModels;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Models;
|
|
|
|
|
|
2023-03-04 10:34:01 +04:00
|
|
|
|
namespace SushiBarFileImplement.Models
|
2023-01-31 15:23:18 +04:00
|
|
|
|
{
|
|
|
|
|
public class Sushi : ISushiModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public string SushiName { get; private set; } = string.Empty;
|
|
|
|
|
public double Price { get; private set; }
|
|
|
|
|
public Dictionary<int, (IIngredientModel, int)> SushiIngredients
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
} = new Dictionary<int, (IIngredientModel, int)>();
|
|
|
|
|
public static Sushi? Create(SushiBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Sushi()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
SushiName = model.SushiName,
|
|
|
|
|
Price = model.Price,
|
|
|
|
|
SushiIngredients = model.SushiIngredients
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(SushiBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SushiName = model.SushiName;
|
|
|
|
|
Price = model.Price;
|
|
|
|
|
SushiIngredients = model.SushiIngredients;
|
|
|
|
|
}
|
|
|
|
|
public SushiViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
SushiName = SushiName,
|
|
|
|
|
Price = Price,
|
|
|
|
|
SushiIngredients = SushiIngredients
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|