78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
using AircraftPlantContracts.BindingModels;
|
|
using AircraftPlantContracts.ViewModels;
|
|
using AircraftPlantDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AircraftPlantListImplement.Models
|
|
{
|
|
/// <summary>
|
|
/// Сущность "Компонент"
|
|
/// </summary>
|
|
public class Component : IComponentModel
|
|
{
|
|
/// <summary>
|
|
/// Идентификатор
|
|
/// </summary>
|
|
public int Id { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Название компонента
|
|
/// </summary>
|
|
public string ComponentName { get; private set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Стоимость компонента
|
|
/// </summary>
|
|
public double Cost { get; set; }
|
|
|
|
/// <summary>
|
|
/// Создание модели компонента
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static Component? Create(ComponentBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Component()
|
|
{
|
|
Id = model.Id,
|
|
ComponentName = model.ComponentName,
|
|
Cost = model.Cost
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Изменение модели компонента
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
public void Update(ComponentBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ComponentName = model.ComponentName;
|
|
Cost = model.Cost;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получение модели компонента
|
|
/// </summary>
|
|
public ComponentViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ComponentName = ComponentName,
|
|
Cost = Cost
|
|
};
|
|
}
|
|
}
|