44 lines
1.2 KiB
C#
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,
|
|
};
|
|
}
|
|
} |