53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using STODataModels;
|
|
using STOContracts.BindingModels;
|
|
using STOContracts.ViewModels;
|
|
|
|
namespace DatabaseImplement
|
|
{
|
|
public class CarPart: ICarPartModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
[Required]
|
|
public string CarPartName { get; private set; } = string.Empty;
|
|
|
|
public double Cost { get; private set; } = 0;
|
|
public static CarPart? Create(CarPartBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new CarPart()
|
|
{
|
|
Id = model.Id,
|
|
CarPartName = model.CarPartName,
|
|
Cost = model.Cost,
|
|
};
|
|
}
|
|
public void Update(CarPartBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Id = model.Id;
|
|
CarPartName = model.CarPartName;
|
|
Cost = model.Cost;
|
|
}
|
|
public CarPartViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
CarPartName = CarPartName,
|
|
Cost = Cost
|
|
};
|
|
}
|
|
}
|