2024-02-25 19:43:57 +04:00
|
|
|
|
using SushiBarContracts.BindingModel;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Models;
|
|
|
|
|
|
2024-02-25 19:52:48 +04:00
|
|
|
|
namespace SushiBarListImplements.Models
|
2024-02-25 19:43:57 +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, (IComponentModel, int)> SushiComponents
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
private set;
|
|
|
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
|
|
|
public static Sushi? Create(SushiBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Sushi()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
SushiName = model.SushiName,
|
|
|
|
|
Price = model.Price,
|
|
|
|
|
SushiComponents = model.SushiComponents
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(SushiBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SushiName = model.SushiName;
|
|
|
|
|
Price = model.Price;
|
|
|
|
|
SushiComponents = model.SushiComponents;
|
|
|
|
|
}
|
|
|
|
|
public SushiViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
SushiName = SushiName,
|
|
|
|
|
Price = Price,
|
|
|
|
|
SushiComponents = SushiComponents
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|