2024-04-16 22:57:41 +04:00
|
|
|
|
using StudentEnrollmentContracts.BindingModels;
|
2024-05-06 20:26:16 +04:00
|
|
|
|
using StudentEnrollmentContracts.ViewModels;
|
2024-04-16 22:57:41 +04:00
|
|
|
|
using StudentEnrollmentDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace StudentEnrollmentDatabaseImplement.Models
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public class ExamPoints //: IExamPointsModel
|
2024-04-16 22:57:41 +04:00
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
[Key]
|
|
|
|
|
public int exampoints_id { get; private set; }
|
2024-04-16 22:57:41 +04:00
|
|
|
|
[Required]
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public int firstexampoints { get; private set; }
|
2024-04-16 22:57:41 +04:00
|
|
|
|
[Required]
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public int secondexampoints { get; private set; }
|
2024-04-16 22:57:41 +04:00
|
|
|
|
[Required]
|
2024-05-06 20:26:16 +04:00
|
|
|
|
public int thirdexampoints { get; private set; }
|
|
|
|
|
public int addpoints { get; private set; }
|
|
|
|
|
public int summary { get; private set; }
|
2024-04-16 22:57:41 +04:00
|
|
|
|
public static ExamPoints? Create(ExamPointsBindingModel model)
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
if (model == null) {
|
|
|
|
|
return null;
|
2024-04-16 22:57:41 +04:00
|
|
|
|
}
|
|
|
|
|
return new ExamPoints()
|
|
|
|
|
{
|
2024-05-06 20:26:16 +04:00
|
|
|
|
exampoints_id = model.Id,
|
|
|
|
|
firstexampoints = model.FirstExamPoints,
|
|
|
|
|
secondexampoints = model.SecondExamPoints,
|
|
|
|
|
thirdexampoints = model.ThirdExamPoints,
|
|
|
|
|
addpoints = model.AddPoints,
|
|
|
|
|
summary = model.FirstExamPoints + model.SecondExamPoints + model.ThirdExamPoints + model.AddPoints,
|
2024-04-16 22:57:41 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(ExamPointsBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-06 20:26:16 +04:00
|
|
|
|
summary -= addpoints;
|
|
|
|
|
addpoints = model.AddPoints;
|
|
|
|
|
summary += model.AddPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ExamPointsViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = exampoints_id,
|
|
|
|
|
FirstExamPoints = firstexampoints,
|
|
|
|
|
SecondExamPoints = secondexampoints,
|
|
|
|
|
ThirdExamPoints = thirdexampoints,
|
|
|
|
|
AddPoints = addpoints,
|
|
|
|
|
Summary = summary,
|
|
|
|
|
};
|
2024-04-16 22:57:41 +04:00
|
|
|
|
}
|
|
|
|
|
}
|