55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
|
using FlowerShopDataModels.Models;
|
|||
|
using FlowerShopContracts.BindingModels;
|
|||
|
using FlowerShopContracts.ViewModels;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace FlowerShopListImplement.Models
|
|||
|
{
|
|||
|
public class Flower : IFlowerModel
|
|||
|
{
|
|||
|
public int Id { get; private set; }
|
|||
|
public string FlowerName { get; private set; } = string.Empty;
|
|||
|
public double Price { get; private set; }
|
|||
|
public Dictionary<int, (IComponentModel, int)> FlowerComponents
|
|||
|
{
|
|||
|
get;
|
|||
|
private set;
|
|||
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|||
|
public static Flower? Create(FlowerBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Flower()
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
FlowerName = model.FlowerName,
|
|||
|
Price = model.Price,
|
|||
|
FlowerComponents = model.FlowerComponents
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(FlowerBindingModel? model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
FlowerName = model.FlowerName;
|
|||
|
Price = model.Price;
|
|||
|
FlowerName = model.FlowerName;
|
|||
|
}
|
|||
|
public FlowerViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
FlowerName = FlowerName,
|
|||
|
Price = Price,
|
|||
|
FlowerComponents = FlowerComponents
|
|||
|
};
|
|||
|
}
|
|||
|
}
|