2023-01-31 15:23:18 +04:00
|
|
|
|
using SushiBarContracts.BindingModels;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Models;
|
|
|
|
|
|
2023-03-04 10:46:26 +04:00
|
|
|
|
namespace SushiBarListImplement.Models
|
2023-01-31 15:23:18 +04:00
|
|
|
|
{
|
|
|
|
|
public class Ingredient : IIngredientModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public string IngredientName { get; private set; } = string.Empty;
|
|
|
|
|
public double Cost { get; set; }
|
|
|
|
|
public static Ingredient? Create(IngredientBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Ingredient()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
IngredientName = model.IngredientName,
|
|
|
|
|
Cost = model.Cost
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(IngredientBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
IngredientName = model.IngredientName;
|
|
|
|
|
Cost = model.Cost;
|
|
|
|
|
}
|
|
|
|
|
public IngredientViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
IngredientName = IngredientName,
|
|
|
|
|
Cost = Cost
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|