2023-04-03 21:27:31 +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.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.ConstrainedExecution;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolAgainStudyDataBaseImplements.Models
|
|
|
|
|
{
|
|
|
|
|
public class Student : IStudent
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public int Class { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string Email { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Login { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("StudentId")]
|
2023-04-05 21:11:51 +04:00
|
|
|
|
public virtual List<Interest> Interests { get; set; } = new();
|
2023-04-03 21:27:31 +04:00
|
|
|
|
[ForeignKey("StudentId")]
|
|
|
|
|
public virtual List<Diy> Diys { get; set; } = new();
|
|
|
|
|
[ForeignKey("StudentId")]
|
|
|
|
|
public virtual List<Product> Products { get; set; } = new();
|
|
|
|
|
public static Student Create(SchoolDataBase context, StudentBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Student()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Class = model.Class,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
Login = model.Login,
|
|
|
|
|
Password = model.Password,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 21:27:31 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(StudentBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
Name = model.Name;
|
|
|
|
|
Class = model.Class;
|
|
|
|
|
Email = model.Email;
|
|
|
|
|
Login = model.Login;
|
|
|
|
|
Password = model.Password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StudentViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Name = Name,
|
|
|
|
|
Class = Class,
|
|
|
|
|
Email = Email,
|
|
|
|
|
Login = Login,
|
2023-04-05 21:11:51 +04:00
|
|
|
|
Password = Password
|
|
|
|
|
|
2023-04-03 21:27:31 +04:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-05 21:11:51 +04:00
|
|
|
|
|
2023-04-03 21:27:31 +04:00
|
|
|
|
}
|
|
|
|
|
}
|