43 lines
1.2 KiB
C#
43 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 Kind : IKindModel
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string Title { get; set; } = string.Empty;
|
|
[Required]
|
|
public int Frequency { get; set; }
|
|
public ICollection<Device> Devices { get; set; } = new List<Device>();
|
|
public static Kind? Create(KindBindingModel model)
|
|
{
|
|
if (model == null)
|
|
return null;
|
|
return new Kind
|
|
{
|
|
Id = model.Id,
|
|
Title = model.Title,
|
|
Frequency = model.Frequency,
|
|
};
|
|
}
|
|
public void Update(KindBindingModel model)
|
|
{
|
|
if (model == null)
|
|
return;
|
|
Id = model.Id;
|
|
Title = model.Title;
|
|
Frequency = model.Frequency;
|
|
}
|
|
public KindViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Title = Title,
|
|
Frequency = Frequency,
|
|
};
|
|
}
|
|
} |