51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using ConstructionFirmDataModels.Models;
|
|
using Subd_4.BindingModels;
|
|
using Subd_4.ViewModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace ConstructionFirmDatabaseImplement.Models
|
|
{
|
|
public class ConstructionMaterial : IConstructionMaterialModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string MaterialName { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public int Cost { get; set; }
|
|
|
|
[Required]
|
|
public int Quantity { get; set; }
|
|
|
|
public static ConstructionMaterial? Create(ConstructionMaterialBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
|
|
return new ConstructionMaterial()
|
|
{
|
|
Id = model.Id,
|
|
MaterialName = model.MaterialName,
|
|
Cost = model.Cost,
|
|
Quantity = model.Quantity
|
|
};
|
|
}
|
|
|
|
public void Update(ConstructionMaterialBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
MaterialName = model.MaterialName;
|
|
Cost = model.Cost;
|
|
Quantity = model.Quantity;
|
|
}
|
|
|
|
public ConstructionMaterialViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
MaterialName = MaterialName,
|
|
Cost = Cost,
|
|
Quantity = Quantity
|
|
};
|
|
}
|
|
}
|