2024-12-17 01:21:56 +04:00

72 lines
2.3 KiB
C#

using System.ComponentModel;
using System.Text.Json.Serialization;
using ProjectGSM.Entities.Enums;
namespace ProjectGSM.Entities;
public class Case
{
public int Id { get; private set; }
[DisplayName("Тип обращения")] public TypeAppeal TypeAppeal { get; private set; }
[DisplayName("Оплата")] public bool Payment { get; private set; } = false;
[DisplayName("Цена")] public decimal Price { get; private set; }
[DisplayName("Цена приговора")] public decimal VictoryPrice { get; private set; }
[DisplayName("Решение")] public bool Verdict { get; private set; } = false;
[Browsable(false)] public int CourtId { get; private set; }
[Browsable(false)] public int ClientId { get; private set; }
[DisplayName("Суд")] public string CourtName { get; private set; } = string.Empty;
[DisplayName("Клиент")] public string ClientName { get; private set; } = string.Empty;
[DisplayName("Описание")] public string Description { get; private set; } = string.Empty;
[DisplayName("Дата создания")] public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
[JsonIgnore] [Browsable(false)] public IEnumerable<CaseAdvocate> Advocates { get; private set; } = [];
[DisplayName("Адвокаты")]
public string AdvocatesNames => string.Join(", ", Advocates.Select(x => $"{x.AdvocateName} ({x.Post})"));
public void SetAdvocates(IEnumerable<CaseAdvocate> advocates)
{
if (advocates != null && advocates.Any())
{
Advocates = advocates;
}
}
// Конструктор для создания сущности
public static Case CreateEntity(
int id,
TypeAppeal typeAppeal,
bool payment,
decimal price,
decimal victoryPrice,
bool verdict,
int courtId,
int clientId,
string description
)
{
return new Case
{
Id = id,
TypeAppeal = typeAppeal,
Payment = payment,
Price = price,
VictoryPrice = victoryPrice,
Verdict = verdict,
CourtId = courtId,
ClientId = clientId,
Description = description ?? string.Empty,
CreatedAt = DateTime.UtcNow
};
}
}