51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using BarContracts.BindingModels;
|
|
using BarContracts.ViewModels;
|
|
using BarDataModels.Models;
|
|
using System.Collections.Generic;
|
|
|
|
namespace BarListImplement.Models
|
|
{
|
|
public class Cocktail : ICocktailModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string CocktailName { get; private set; } = string.Empty;
|
|
public double Price { get; private set; }
|
|
public Dictionary<int, (IComponentModel, int)> CocktailComponents
|
|
{
|
|
get;
|
|
private set;
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
public static Cocktail? Create(CocktailBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Cocktail()
|
|
{
|
|
Id = model.Id,
|
|
CocktailName = model.CocktailName,
|
|
Price = model.Price,
|
|
CocktailComponents = model.CocktailComponents
|
|
};
|
|
}
|
|
public void Update(CocktailBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
CocktailName = model.CocktailName;
|
|
Price = model.Price;
|
|
CocktailComponents = model.CocktailComponents;
|
|
}
|
|
public CocktailViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
CocktailName = CocktailName,
|
|
Price = Price,
|
|
CocktailComponents = CocktailComponents
|
|
};
|
|
}
|
|
}
|