62 lines
1.9 KiB
C#
62 lines
1.9 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;
|
|
using UniversityModels.Enums;
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
namespace UniversityDataBaseImplemet.Models
|
|
{
|
|
public class User : IUserModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public string Login { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
[Required]
|
|
public Role Role { get; set; }
|
|
[ForeignKey("UserId")]
|
|
public virtual List<Student> Students { get; set; } = new();
|
|
[ForeignKey("UserId")]
|
|
public virtual List<Document> Documents { get; set; } = new();
|
|
[ForeignKey("UserId")]
|
|
public virtual List<EducationStatus> EducationStatuses { get; set; } = new();
|
|
[ForeignKey("UserId")]
|
|
public virtual List<Discipline> Disciplines { get; set; } = new();
|
|
[ForeignKey("UserId")]
|
|
public virtual List<EducationGroup> EducationGroups { get; set; } = new();
|
|
[ForeignKey("UserId")]
|
|
public virtual List<Stream> Streams { get; set; } = new();
|
|
public static User Create(UserBindingModel model)
|
|
{
|
|
return new User()
|
|
{
|
|
Id = model.Id,
|
|
Login = model.Login,
|
|
Password = model.Password,
|
|
Role = model.Role
|
|
};
|
|
}
|
|
public void Update(UserBindingModel model)
|
|
{
|
|
Login = model.Login;
|
|
Password = model.Password;
|
|
Role = model.Role;
|
|
}
|
|
public UserViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Login = Login,
|
|
Password = Password,
|
|
Role = Role
|
|
};
|
|
}
|
|
}
|