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

50 lines
1.2 KiB
C#

using DressAtelierContracts.BindingModels;
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 Material : IMaterialModel
{
public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; }
public int ID { get; private set; }
public static Material? Create(MaterialBindingModel? model)
{
if (model == null)
{
return null;
}
return new Material()
{
ID = model.ID,
ComponentName = model.ComponentName,
Cost = model.Cost
};
}
public void Update(MaterialBindingModel? model)
{
if (model == null)
{
return;
}
ComponentName = model.ComponentName;
Cost = model.Cost;
}
public MaterialViewModel GetViewModel => new()
{
ID = ID,
ComponentName = ComponentName,
Cost = Cost
};
}
}