2024-11-04 22:26:40 +04:00
|
|
|
|
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 Vacancy : IVacancyModel
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
|
|
|
|
public int CompanyId { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string JobTitle { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Requirements { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Responsibilities { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public JobTypeEnum JobType { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? Salary { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? Description { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public VacancyStatusEnum Status { get; set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime CreatedAt { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? Tags { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
public virtual Company Company { get; set; }
|
|
|
|
|
|
|
|
|
|
[ForeignKey("VacancyId")]
|
|
|
|
|
public virtual List<Resume> Resumes { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public static Vacancy? Create(VacancyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Vacancy()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
CompanyId = model.CompanyId,
|
|
|
|
|
JobTitle = model.JobTitle,
|
|
|
|
|
Requirements = model.Requirements,
|
|
|
|
|
Responsibilities = model.Responsibilities,
|
|
|
|
|
JobType = model.JobType,
|
|
|
|
|
Salary = model.Salary,
|
|
|
|
|
Description = model.Description,
|
|
|
|
|
Status = model.Status,
|
2024-11-19 16:45:59 +04:00
|
|
|
|
CreatedAt = DateTime.Now.ToUniversalTime(),
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Tags = model.Tags
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Vacancy Create(VacancyViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Vacancy
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
CompanyId = model.CompanyId,
|
|
|
|
|
JobTitle = model.JobTitle,
|
|
|
|
|
Requirements = model.Requirements,
|
|
|
|
|
Responsibilities = model.Responsibilities,
|
|
|
|
|
JobType = model.JobType,
|
|
|
|
|
Salary = model.Salary,
|
|
|
|
|
Description = model.Description,
|
|
|
|
|
Status = model.Status,
|
2024-11-23 21:39:18 +04:00
|
|
|
|
CreatedAt = DateTime.Now.ToUniversalTime(),
|
2024-11-04 22:26:40 +04:00
|
|
|
|
Tags = model.Tags
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(VacancyBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CompanyId = model.CompanyId;
|
|
|
|
|
JobTitle = model.JobTitle;
|
|
|
|
|
Requirements = model.Requirements;
|
|
|
|
|
Responsibilities = model.Responsibilities;
|
|
|
|
|
JobType = model.JobType;
|
|
|
|
|
Salary = model.Salary;
|
|
|
|
|
Description = model.Description;
|
|
|
|
|
Status = model.Status;
|
|
|
|
|
Tags = model.Tags;
|
|
|
|
|
}
|
|
|
|
|
public VacancyViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
CompanyId = CompanyId,
|
|
|
|
|
JobTitle = JobTitle,
|
|
|
|
|
Requirements = Requirements,
|
|
|
|
|
Responsibilities = Responsibilities,
|
|
|
|
|
JobType = JobType,
|
|
|
|
|
Salary = Salary,
|
|
|
|
|
Description = Description,
|
|
|
|
|
Status = Status,
|
|
|
|
|
CreatedAt = CreatedAt,
|
|
|
|
|
Tags = Tags
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|