10Г Егор Романов 5ddd734aa6 rename
2023-03-07 12:56:54 +04:00

56 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SecuritySystemContracts.BindingModels;
using SecuritySystemContracts.ViewModels;
using SecuritySystemDataModels.Models;
namespace SecuritySystemListImplement.Models
{
public class Secure : IManufactureModel
{
public int Id { get; private set; }
public string ManufactureName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> ManufactureComponents
{
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
public static Secure? Create(ManufactureBindingModel? model)
{
if (model == null)
{
return null;
}
return new Secure()
{
Id = model.Id,
ManufactureName = model.ManufactureName,
Price = model.Price,
ManufactureComponents = model.ManufactureComponents
};
}
public void Update(ManufactureBindingModel? model)
{
if (model == null)
{
return;
}
ManufactureName = model.ManufactureName;
Price = model.Price;
ManufactureComponents = model.ManufactureComponents;
}
public ManufactureViewModel GetViewModel => new()
{
Id = Id,
ManufactureName = ManufactureName,
Price = Price,
ManufactureComponents = ManufactureComponents
};
}
}