2023-04-03 20:19:36 +04:00
|
|
|
|
using SchoolAgainStudyContracts.BindingModel;
|
|
|
|
|
using SchoolAgainStudyContracts.ViewModel;
|
|
|
|
|
using SchoolAgainStudyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolAgainStudyDataBaseImplements.Models
|
|
|
|
|
{
|
|
|
|
|
public class Teacher : ITeacher
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Post { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
2023-05-17 21:29:39 +04:00
|
|
|
|
public string Email { get; set; } = string.Empty;
|
2023-04-03 20:19:36 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string Login { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Password { get; set; } = string.Empty;
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 20:19:36 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
[ForeignKey("TeacherId")]
|
2023-04-05 21:11:51 +04:00
|
|
|
|
public virtual List<Material> Materials { get; set; } = new();
|
2023-04-03 20:19:36 +04:00
|
|
|
|
[ForeignKey("TeacherId")]
|
|
|
|
|
public virtual List<Task> Tasks { get; set; } = new();
|
|
|
|
|
[ForeignKey("TeacherId")]
|
|
|
|
|
public virtual List<Lesson> Lessons { get; set; } = new();
|
|
|
|
|
public static Teacher Create(SchoolDataBase context, TeacherBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Teacher()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Post = model.Post,
|
2023-05-17 21:29:39 +04:00
|
|
|
|
Email = model.Email,
|
2023-04-03 20:19:36 +04:00
|
|
|
|
Login = model.Login,
|
|
|
|
|
Password = model.Password,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 20:19:36 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(TeacherBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
Name = model.Name;
|
|
|
|
|
Post = model.Post;
|
2023-05-17 21:29:39 +04:00
|
|
|
|
Email = model.Email;
|
2023-04-03 20:19:36 +04:00
|
|
|
|
Login = model.Login;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TeacherViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Name = Name,
|
|
|
|
|
Post = Post,
|
2023-05-17 21:29:39 +04:00
|
|
|
|
Email = Email,
|
2023-04-03 20:19:36 +04:00
|
|
|
|
Login = Login,
|
|
|
|
|
Password = Password,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 20:19:36 +04:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 20:19:36 +04:00
|
|
|
|
}
|
|
|
|
|
}
|