54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using EkzamenContracts.BindingModels;
|
|
using EkzamenContracts.ViewModels;
|
|
using EkzamenDataModels;
|
|
|
|
namespace EkzamenDatabaseImplement
|
|
{
|
|
public class Group : IGroupModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
public static Group? Create(GroupBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Group()
|
|
{
|
|
Name = model.Name,
|
|
Direction = model.Direction,
|
|
Created = model.Created,
|
|
Id = model.Id,
|
|
};
|
|
}
|
|
|
|
public void Update(GroupBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Direction = model.Direction;
|
|
Id = model.Id;
|
|
}
|
|
public GroupViewModel GetViewModel =>
|
|
new()
|
|
{
|
|
Name = Name,
|
|
Direction = Direction,
|
|
Created = Created,
|
|
Id = Id,
|
|
};
|
|
|
|
[Required]
|
|
public string Name { get; set; }
|
|
[Required]
|
|
public string Direction { get; set; }
|
|
public DateTime Created { get; set; }
|
|
|
|
public List<Student> Students { get; set; }
|
|
}
|
|
}
|