пу пу пу
This commit is contained in:
parent
b7f880a90a
commit
d3343f2964
@ -135,7 +135,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
Name = element.Name,
|
||||
DateCreate = element.DateCreate,
|
||||
Status = element.Status,
|
||||
CaseClients = element.CaseClients
|
||||
CaseClients = element.CaseClients,
|
||||
ExecutorId = element.ExecutorId,
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -141,8 +141,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
FIO = model.FIO,
|
||||
Phone = model.Phone,
|
||||
Email = model.Email
|
||||
|
||||
Email = model.Email,
|
||||
ExecutorId = model.ExecutorId,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
|
@ -104,7 +104,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
Id = element.Id,
|
||||
VisitDate = element.VisitDate,
|
||||
HearingId = element.HearingId,
|
||||
VisitClients = element.VisitClients
|
||||
VisitClients = element.VisitClients,
|
||||
ExecutorId = element.ExecutorId,
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -12,5 +12,6 @@ namespace LawFirmContracts.BindingModels
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public Dictionary<int, IClientModel> CaseClients { get; set; } = new();
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ namespace LawFirmContracts.BindingModels
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ namespace LawFirmContracts.BindingModels
|
||||
public DateTime VisitDate { get; set; }
|
||||
public int HearingId { get; set; }
|
||||
public Dictionary<int, IClientModel> VisitClients { get; set; } = new();
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,6 @@
|
||||
public string? CaseType { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@
|
||||
public string? FIO { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public int? ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,6 @@
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int? HearingId { get; set; }
|
||||
public int? ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,5 +18,6 @@ namespace LawFirmContracts.ViewModels
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
public Dictionary<int, IClientModel> CaseClients { get; set; } = new();
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace LawFirmContracts.ViewModels
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Телефон клиента")]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ namespace LawFirmContracts.ViewModels
|
||||
public DateTime VisitDate { get; set; }
|
||||
public int HearingId { get; set; }
|
||||
public Dictionary<int, IClientModel> VisitClients { get; set; } = new();
|
||||
public int ExecutorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,33 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Cases.Include(x => x.CaseClients)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<CaseViewModel> GetFilteredList(CaseSearchModel model)
|
||||
{
|
||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue
|
||||
&& !model.ExecutorId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
if (model.ExecutorId.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Cases
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.ExecutorId == model.ExecutorId).ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Cases.Include(x => x.CaseClients)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel).ToList()
|
||||
.ToList();
|
||||
@ -46,14 +56,14 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public CaseViewModel? GetElement(CaseSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Name))
|
||||
if (!model.Id.HasValue && !model.ExecutorId.HasValue && string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Cases.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel; //имя дела не должно повторяться, уникальное должно быть
|
||||
?.GetViewModel;
|
||||
|
||||
}
|
||||
public CaseViewModel? Insert(CaseBindingModel model)
|
||||
|
@ -15,10 +15,11 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
||||
&& string.IsNullOrEmpty(model.Phone))
|
||||
&& string.IsNullOrEmpty(model.Phone) && !model.ExecutorId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
@ -30,6 +31,22 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ExecutorId.HasValue && model.Id.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.ExecutorId.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
@ -42,7 +59,7 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
||||
&& string.IsNullOrEmpty(model.Phone))
|
||||
&& string.IsNullOrEmpty(model.Phone) && !model.ExecutorId.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -50,7 +67,8 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email)
|
||||
&& x.Email == model.Email) || (model.Id.HasValue && x.Id == model.Id))
|
||||
&& x.Email == model.Email) || (model.Id.HasValue && x.Id == model.Id) || (model.ExecutorId.HasValue
|
||||
&& x.ExecutorId == model.ExecutorId))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
|
@ -13,7 +13,7 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Clients)
|
||||
.Include(x => x.Clients)
|
||||
.ThenInclude(x => x.Client)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -21,38 +21,30 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredList(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ExecutorId.HasValue
|
||||
&& !model.VisitDate.HasValue && !model.HearingId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
if (model.ExecutorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.ExecutorId == model.ExecutorId && x.VisitDate >= model.DateFrom && x.VisitDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
else if (model.ExecutorId.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.VisitDate >= model.DateFrom && x.VisitDate <= model.DateTo)
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredDateList(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
@ -71,16 +63,44 @@ namespace LawFirmDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredDateList(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ExecutorId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.Where(x => x.VisitDate >= model.DateFrom && x.VisitDate <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public VisitViewModel? GetElement(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && !model.VisitDate.HasValue && !model.HearingId.HasValue)
|
||||
if (!model.Id.HasValue && !model.ExecutorId.HasValue
|
||||
&& !model.VisitDate.HasValue && !model.HearingId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new LawFirmDatabase();
|
||||
return context.Visits.Include(x => x.Clients).ThenInclude(x => x.Client)
|
||||
.FirstOrDefault(x => (model.HearingId.HasValue && x.Hearing == model.HearingId)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))
|
||||
.FirstOrDefault(x => (model.HearingId.HasValue && x.HearingId == model.HearingId) || (model.Id.HasValue
|
||||
&& x.Id == model.Id) || (model.ExecutorId.HasValue
|
||||
&& x.ExecutorId == model.ExecutorId))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public VisitViewModel? Insert(VisitBindingModel model)
|
||||
|
@ -20,6 +20,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
[Required]
|
||||
public CaseStatus Status { get; private set; }
|
||||
private Dictionary<int, IClientModel>? _caseClients = null;
|
||||
public int ExecutorId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IClientModel> CaseClients
|
||||
@ -38,8 +39,6 @@ namespace LawFirmDatabaseImplement.Models
|
||||
}
|
||||
[ForeignKey("CaseId")]
|
||||
public virtual List<CaseClient> Clients { get; set; } = new();
|
||||
[ForeignKey("CaseId")]
|
||||
public virtual List<Hearing> Hearings { get; set; } = new();
|
||||
public static Case Create(LawFirmDatabase context, CaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -53,6 +52,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Status = model.Status,
|
||||
ExecutorId = model.ExecutorId,
|
||||
Clients = model.CaseClients.Select(x => new CaseClient
|
||||
{
|
||||
Client = context.Clients.First(y => y.Id == x.Key)
|
||||
@ -72,7 +72,6 @@ namespace LawFirmDatabaseImplement.Models
|
||||
|
||||
|
||||
if (model.DateImplement.HasValue) DateImplement = model.DateImplement;
|
||||
if (!model.CompanyId.HasValue) CompanyId = model.CompanyId;
|
||||
}
|
||||
public CaseViewModel GetViewModel => new()
|
||||
{
|
||||
@ -81,6 +80,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
CaseType = CaseType,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
ExecutorId = ExecutorId,
|
||||
Status = Status,
|
||||
CaseClients = CaseClients,
|
||||
};
|
||||
|
@ -19,6 +19,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
public virtual List<CaseClient> CaseClients { get; set; } = new();
|
||||
[ForeignKey("ClientId")]
|
||||
public virtual List<VisitClient> ClientVisits { get; set; } = new();
|
||||
public int ExecutorId { get; set; }
|
||||
|
||||
public static Client? Create(ClientBindingModel? model)
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
FIO = model.FIO,
|
||||
Email = model.Email,
|
||||
Phone = model.Phone,
|
||||
ExecutorId = model.ExecutorId,
|
||||
};
|
||||
}
|
||||
public static Client Create(ClientViewModel model)
|
||||
@ -42,6 +44,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
FIO = model.FIO,
|
||||
Email = model.Email,
|
||||
Phone = model.Phone,
|
||||
ExecutorId = model.ExecutorId,
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel? model)
|
||||
@ -60,6 +63,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
FIO = FIO,
|
||||
Email = Email,
|
||||
Phone = Phone,
|
||||
ExecutorId = ExecutorId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
public int HearingId { get; private set; }
|
||||
public Hearing Hearing { get; set; } = null!;
|
||||
//---
|
||||
public int? CompanyId { get; set; }
|
||||
public int ExecutorId { get; set; }
|
||||
|
||||
private Dictionary<int, IClientModel>? _visitClients = null;
|
||||
[NotMapped]
|
||||
@ -37,8 +37,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
}
|
||||
[ForeignKey("VisitId")]
|
||||
public virtual List<VisitClient> Clients { get; set; } = new();
|
||||
public static Visit? Create(LawFirmDatabase context,
|
||||
VisitBindingModel? model)
|
||||
public static Visit? Create(LawFirmDatabase context, VisitBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -54,6 +53,7 @@ namespace LawFirmDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
VisitDate = model.VisitDate,
|
||||
HearingId = model.HearingId,
|
||||
ExecutorId = model.ExecutorId,
|
||||
Hearing = context.Hearings.First(x => x.Id == model.HearingId),
|
||||
Clients = model.VisitClients.Select(x => new VisitClient
|
||||
{
|
||||
@ -78,7 +78,8 @@ namespace LawFirmDatabaseImplement.Models
|
||||
Id = Id,
|
||||
VisitDate = VisitDate,
|
||||
HearingId = HearingId,
|
||||
VisitClients = VisitClients
|
||||
VisitClients = VisitClients,
|
||||
ExecutorId = ExecutorId,
|
||||
};
|
||||
public void UpdateClients(LawFirmDatabase context,
|
||||
VisitBindingModel model)
|
||||
|
Loading…
Reference in New Issue
Block a user