PIbd-23_Elatomtsev_L.K._SUB.../DeviceDatabaseImplement/Models/Cabinet.cs
2024-05-20 05:17:39 +04:00

44 lines
1.2 KiB
C#

using DeviceDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using DeviceContracts.BindingModels;
using DeviceContracts.ViewModels;
namespace DeviceDatabaseImplement.Models
{
public class Cabinet : ICabinetModel
{
public int Id { get; set; }
[Required]
public string Room { get; set; } = string.Empty;
[Required]
public int Building { get; set; }
public ICollection<Cabinet> Cabinets { get; set; } =
new List<Cabinet>();
public static Cabinet? Create(CabinetBindingModel model)
{
if (model == null)
return null;
return new Cabinet
{
Id = model.Id,
Room = model.Room,
Building = model.Building,
};
}
public void Update(CabinetBindingModel model)
{
if (model == null)
return;
Id = model.Id;
Room = model.Room;
Building = model.Building;
}
public CabinetViewModel GetViewModel => new()
{
Id = Id,
Room = Room,
Building = Building,
};
}
}