using CandidateReviewContracts.BindingModels; using CandidateReviewContracts.ViewModels; using CandidateReviewDataModels.Enums; using CandidateReviewDataModels.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace CandidateReviewDatabaseImplement.Models { public class Resume : IResumeModel { [Required] public int VacancyId { get; set; } [Required] public int UserId { get; set; } [Required] public string Title { get; set; } = string.Empty; [Required] public string Experience { get; set; } = string.Empty; [Required] public string Education { get; set; } = string.Empty; public string? PhotoFilePath { get; set; } public string? Description { get; set; } [Required] public string Skills { get; set; } = string.Empty; [Required] public ResumeStatusEnum Status { get; set; } public int Id { get; set; } [ForeignKey("ResumeId")] public virtual Assessment Assessment { get; set; } = new(); public virtual Vacancy Vacancy { get; set; } public virtual User User { get; set; } public static Resume? Create(ResumeBindingModel model) { if (model == null) { return null; } return new Resume() { Id = model.Id, VacancyId = model.VacancyId, UserId = model.UserId, Title = model.Title, Experience = model.Experience, Education = model.Education, PhotoFilePath = model.PhotoFilePath, Description = model.Description, Skills = model.Skills, Status = model.Status }; } public static Resume Create(ResumeViewModel model) { return new Resume { Id = model.Id, VacancyId = model.VacancyId, UserId = model.UserId, Title = model.Title, Experience = model.Experience, Education = model.Education, PhotoFilePath = model.PhotoFilePath, Description = model.Description, Skills = model.Skills, Status = model.Status }; } public void Update(ResumeBindingModel model) { if (model == null) { return; } VacancyId = model.VacancyId; UserId = model.UserId; Title = model.Title; Experience = model.Experience; Education = model.Education; PhotoFilePath = model.PhotoFilePath; Description = model.Description; Skills = model.Skills; Status = model.Status; } public ResumeViewModel GetViewModel => new() { Id = Id, VacancyId = VacancyId, UserId = UserId, Title = Title, Experience = Experience, Education = Education, PhotoFilePath = PhotoFilePath, Description = Description, Skills = Skills, Status = Status }; } }