2024-04-16 22:57:41 +04:00
|
|
|
|
using StudentEnrollmentContracts.BindingModels;
|
|
|
|
|
using StudentEnrollmentContracts.ViewModels;
|
|
|
|
|
using StudentEnrollmentDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace StudentEnrollmentDatabaseImplement.Models
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public class Faculty // : IFacultyModel
|
2024-04-16 22:57:41 +04:00
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
[Key]
|
|
|
|
|
public int faculty_id { get; private set; }
|
2024-04-16 22:57:41 +04:00
|
|
|
|
[Required]
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public string name { get; private set;} = string.Empty;
|
2024-04-16 22:57:41 +04:00
|
|
|
|
public static Faculty? Create(FacultyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
return null;
|
|
|
|
|
return new Faculty()
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
faculty_id = model.Id,
|
|
|
|
|
name = model.FacultyName,
|
2024-04-16 22:57:41 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(FacultyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
return;
|
2024-05-06 20:26:16 +04:00
|
|
|
|
name = model.FacultyName;
|
2024-04-16 22:57:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FacultyViewModel GetViewModel => new()
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
Id = faculty_id,
|
|
|
|
|
FacultyName = name,
|
2024-04-16 22:57:41 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|