using CandidateReviewContracts.BindingModels;
using CandidateReviewContracts.ViewModels;
using System.ComponentModel.DataAnnotations;
using System.Net;

namespace CandidateReviewDatabaseImplement.Models
{
    public class AssessmentCriterion
    {
        public int Id { get; set; }
        [Required]
        public int AssessmentId { get; set; }
        [Required]
        public int CriterionId { get; set; }
        [Required]
        public int Value { get; set; }

        public static AssessmentCriterion? Create(AssessmentCriterionModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new AssessmentCriterion()
            {
                Id = model.Id,
                AssessmentId = model.AssessmentId,
                CriterionId = model.CriterionId,
                Value = model.Value
            };
        }

        public AssessmentCriterionViewModel GetViewModel => new()
        {
            Id = Id,
            AssessmentId = AssessmentId,
            CriterionId = CriterionId,
            Value = Value
        };
    }
}
