56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using FurnitureAssemblyDataModels.Models;
|
|
using FurnitureAssemblyContracts.BindingModels;
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FurnitureAssemblyListImplement.Models
|
|
{
|
|
public class Furniture : IFurnitureModel
|
|
{
|
|
public int Id { get; private set; }
|
|
public string FurnitureName { get; private set; } = string.Empty;
|
|
public double Price { get; private set; }
|
|
public Dictionary<int, (IComponentModel, int)> FurnitureComponents
|
|
{
|
|
get;
|
|
private set;
|
|
} = new Dictionary<int, (IComponentModel, int)>();
|
|
public static Furniture? Create(FurnitureBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Furniture()
|
|
{
|
|
Id = model.Id,
|
|
FurnitureName = model.FurnitureName,
|
|
Price = model.Price,
|
|
FurnitureComponents = model.FurnitureComponents
|
|
};
|
|
}
|
|
public void Update(FurnitureBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
FurnitureName = model.FurnitureName;
|
|
Price = model.Price;
|
|
FurnitureComponents = model.FurnitureComponents;
|
|
}
|
|
public FurnitureViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
FurnitureName = FurnitureName,
|
|
Price = Price,
|
|
FurnitureComponents = FurnitureComponents
|
|
};
|
|
}
|
|
|
|
}
|