using AircraftPlantContracts.BindingModels;
using AircraftPlantContracts.ViewModels;
using AircraftPlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AircraftPlantListImplement.Models
{
///
/// Сущность "Изделие"
///
public class Plane : IPlaneModel
{
///
/// Идентификатор
///
public int Id { get; private set; }
///
/// Название изделия
///
public string PlaneName { get; private set; } = string.Empty;
///
/// Стоимость изделия
///
public double Price { get; private set; }
///
/// Коллекция компонентов изделия
///
public Dictionary PlaneComponents
{
get;
private set;
} = new Dictionary();
///
/// Создание модели изделия
///
///
///
public static Plane? Create(PlaneBindingModel? model)
{
if (model == null)
{
return null;
}
return new Plane()
{
Id = model.Id,
PlaneName = model.PlaneName,
Price = model.Price,
PlaneComponents = model.PlaneComponents
};
}
///
/// Изменение модели изделия
///
///
public void Update(PlaneBindingModel? model)
{
if (model == null)
{
return;
}
PlaneName = model.PlaneName;
Price = model.Price;
PlaneComponents = model.PlaneComponents;
}
///
/// Получение модели изделия
///
public PlaneViewModel GetViewModel => new()
{
Id = Id,
PlaneName = PlaneName,
Price = Price,
PlaneComponents = PlaneComponents
};
}
}