PIbd-23-Lisov-N.A-SewingDre.../DressAtelierListImplement/Models/Dress.cs

59 lines
1.6 KiB
C#
Raw Normal View History

using DressAtelierContracts.BindingModels;
using DressAtelierContracts.BusinessLogicContracts;
using DressAtelierContracts.SearchModels;
using DressAtelierContracts.ViewModels;
using DressAtelierDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DressAtelierListImplement.Models
{
public class Dress : IDressModel
{
public int ID { get; private set; }
2023-02-13 02:45:41 +04:00
public string DressName { get; private set; } = string.Empty;
public double Price { get; private set; }
2023-02-13 02:45:41 +04:00
public Dictionary<int, (IMaterialModel, int)> DressComponents { get; private set; } = new Dictionary<int, (IMaterialModel, int)>();
public static Dress? Create(DressBindingModel? model)
{
if (model == null)
{
return null;
}
return new Dress()
{
ID = model.ID,
2023-02-13 02:45:41 +04:00
DressName = model.DressName,
Price = model.Price,
2023-02-13 02:45:41 +04:00
DressComponents = model.DressComponents
};
}
public void Update(DressBindingModel? model)
{
if (model == null)
{
return;
}
2023-02-13 02:45:41 +04:00
DressName = model.DressName;
Price = model.Price;
2023-02-13 02:45:41 +04:00
DressComponents = model.DressComponents;
}
public DressViewModel GetViewModel => new()
{
ID = ID,
2023-02-13 02:45:41 +04:00
DressName = DressName,
Price = Price,
2023-02-13 02:45:41 +04:00
DressComponents = DressComponents
};
}
}