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

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,
};
}
}