CourseWork_KPO/CandidateReviewDatabaseImplement/Models/Criterion.cs

53 lines
1.4 KiB
C#

using CandidateReviewContracts.BindingModels;
using CandidateReviewContracts.ViewModels;
using CandidateReviewDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CandidateReviewDatabaseImplement.Models
{
public class Criterion : ICriterionModel
{
[Required]
public string Name { get; set; } = string.Empty;
public int Id { get; set; }
[ForeignKey("CriterionId")]
public virtual List<AssessmentCriterion> AssessmentCriterions { get; set; } = new();
public static Criterion? Create(CriterionBindingModel model)
{
if (model == null)
{
return null;
}
return new Criterion()
{
Id = model.Id,
Name = model.Name
};
}
public static Criterion Create(CriterionViewModel model)
{
return new Criterion
{
Id = model.Id,
Name = model.Name
};
}
public void Update(CriterionBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public CriterionViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}