58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UniversityContracts.BindingModels;
|
|
using UniversityContracts.ViewModels;
|
|
using UniversityModels.Models;
|
|
|
|
namespace UniversityDataBaseImplemet.Models
|
|
{
|
|
public class EducationGroup : IEducationGroupModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public int NumberOfStudent { get; set; }
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
[ForeignKey("EducationGroupId")]
|
|
public virtual List<EducationGroupDocument> EducationGroupDocument { get; set; } = new();
|
|
[ForeignKey("EducationGroupId")]
|
|
public virtual List<EducationGroupStream> EducationGroupStream { get; set; } = new();
|
|
public virtual User User { get; set; }
|
|
|
|
public static EducationGroup? Create(EducationGroupBindingModel model)
|
|
{
|
|
return new EducationGroup()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
UserId = model.UserId,
|
|
NumberOfStudent= model.NumberOfStudent
|
|
};
|
|
}
|
|
public void Update(EducationGroupBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
UserId = model.UserId;
|
|
}
|
|
public EducationGroupViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
UserId = UserId,
|
|
NumberOfStudent = NumberOfStudent
|
|
};
|
|
|
|
}
|
|
}
|