2024-05-01 02:32:04 +04:00
|
|
|
|
using LawCompanyDataModels.Models;
|
|
|
|
|
using LawCompanyContracts.BindingModels;
|
|
|
|
|
using LawCompanyContracts.ViewModels;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace LawCompanyDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Client : IClientModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string FIO { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Email { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Phone { get; private set; } = string.Empty;
|
|
|
|
|
[ForeignKey("ClientId")]
|
|
|
|
|
public virtual List<CaseClient> CaseClients { get; set; } = new();
|
|
|
|
|
[ForeignKey("ClientId")]
|
|
|
|
|
public virtual List<VisitClient> ClientVisits { get; set; } = new();
|
2024-05-01 15:08:34 +04:00
|
|
|
|
public int ExecutorId { get; set; }
|
2024-05-27 02:43:57 +04:00
|
|
|
|
public virtual Executor Executor { get; set; }
|
2024-05-01 02:32:04 +04:00
|
|
|
|
|
|
|
|
|
public static Client? Create(ClientBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Client()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
FIO = model.FIO,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
Phone = model.Phone,
|
2024-05-01 15:08:34 +04:00
|
|
|
|
ExecutorId = model.ExecutorId,
|
2024-05-01 02:32:04 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Client Create(ClientViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Client
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
FIO = model.FIO,
|
|
|
|
|
Email = model.Email,
|
|
|
|
|
Phone = model.Phone,
|
2024-05-01 15:08:34 +04:00
|
|
|
|
ExecutorId = model.ExecutorId,
|
2024-05-01 02:32:04 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(ClientBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
FIO = model.FIO;
|
|
|
|
|
Email = model.Email;
|
|
|
|
|
Phone = model.Phone;
|
|
|
|
|
}
|
|
|
|
|
public ClientViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
FIO = FIO,
|
|
|
|
|
Email = Email,
|
|
|
|
|
Phone = Phone,
|
2024-05-01 15:08:34 +04:00
|
|
|
|
ExecutorId = ExecutorId,
|
2024-05-01 02:32:04 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|