SUBD_SchoolSchedule/SchoolSchedule/SchoolScheduleDataBaseImplement/Models/Teacher.cs
2024-04-08 22:02:19 +04:00

46 lines
1.1 KiB
C#

using SchoolScheduleContracts.BindingModels;
using SchoolScheduleContracts.ViewModels;
using SchoolScheduleDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchoolScheduleDataBaseImplement.Models
{
public class Teacher : ITeacherModel
{
public int Id { get; private set; }
[Required]
public string FullName { get; private set; } = string.Empty;
[ForeignKey("TeacherId")]
public virtual List<Lesson> Lessons { get; set; } = new();
[ForeignKey("TeacherId")]
public virtual List<Grade> Grade { get; set; } = new();
public static Teacher Create(SchoolScheduleDataBase context, TeacherBindingModel model)
{
return new Teacher()
{
Id = model.Id,
FullName = model.FullName
};
}
public void Update(SchoolScheduleDataBase context, TeacherBindingModel model)
{
FullName = model.FullName;
}
public TeacherViewModel GetViewModel => new()
{
Id = Id,
FullName = FullName,
};
}
}