88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using CandidateReviewContracts.BindingModels;
|
|
using CandidateReviewContracts.ViewModels;
|
|
using CandidateReviewDataModels.Models;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace CandidateReviewDatabaseImplement.Models
|
|
{
|
|
public class Company : ICompanyModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
public string? LogoFilePath { get; set; }
|
|
|
|
public string? Description { get; set; }
|
|
|
|
public string? Website { get; set; }
|
|
|
|
public string? Address { get; set; }
|
|
|
|
public string? Contacts { get; set; }
|
|
|
|
public int Id { get; set; }
|
|
|
|
[ForeignKey("CompanyId")]
|
|
public virtual List<User> Users { get; set; } = new();
|
|
|
|
[ForeignKey("CompanyId")]
|
|
public virtual List<Vacancy> Vacancies { get; set; } = new();
|
|
|
|
public static Company? Create(CompanyBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Company()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
LogoFilePath = model.LogoFilePath,
|
|
Description = model.Description,
|
|
Website = model.Website,
|
|
Address = model.Address,
|
|
Contacts = model.Contacts
|
|
};
|
|
}
|
|
|
|
public static Company Create(CompanyViewModel model)
|
|
{
|
|
return new Company
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
LogoFilePath = model.LogoFilePath,
|
|
Description = model.Description,
|
|
Website = model.Website,
|
|
Address = model.Address,
|
|
Contacts = model.Contacts
|
|
};
|
|
}
|
|
|
|
public void Update(CompanyBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
LogoFilePath = model.LogoFilePath;
|
|
Description = model.Description;
|
|
Website = model.Website;
|
|
Address = model.Address;
|
|
Contacts = model.Contacts;
|
|
}
|
|
public CompanyViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
LogoFilePath = LogoFilePath,
|
|
Description = Description,
|
|
Website = Website,
|
|
Address = Address,
|
|
Contacts = Contacts
|
|
};
|
|
}
|
|
}
|