using CandidateReviewContracts.BindingModels;
using CandidateReviewContracts.ViewModels;
using CandidateReviewDataModels.Models;

namespace CandidateReviewDatabaseImplement.Models
{
    public class Assessment : IAssessmentModel
    {
        public int? UserId { get; set; }

        public int? ResumeId { get; set; }

        public string? Comment { get; set; }

        public int Id { get; set; }
        public virtual User User { get; set; }
        public virtual Resume Resume { get; set; }

        public static Assessment Create(CandidateReviewDatabase context, AssessmentBindingModel model)
        {
            return new Assessment()
            {
                Id = model.Id,
                ResumeId = model.ResumeId,
                UserId = model.UserId,
                Comment = model.Comment
            };
        }

        public void Update(AssessmentBindingModel model)
        {
            if (model == null)
            {
                return;
            }
            ResumeId = model.ResumeId;
            UserId = model.UserId;
            Comment = model.Comment;
        }

        public AssessmentViewModel GetViewModel => new()
        {
            Id = Id,
            ResumeId = ResumeId,
            UserId = UserId,
            Comment = Comment
        };
    }
}
