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; }

        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
        };
    }
}
