правки
This commit is contained in:
parent
65decf8f3f
commit
0e7a46e2e1
@ -142,8 +142,6 @@ namespace LawCompanyBusinessLogic.BusinessLogics
|
|||||||
FIO = model.FIO,
|
FIO = model.FIO,
|
||||||
Phone = model.Phone,
|
Phone = model.Phone,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
ExecutorId = model.ExecutorId,
|
|
||||||
|
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -1,140 +1,140 @@
|
|||||||
using LawCompanyContracts.BindingModels;
|
using LawCompanyDataModels.Models;
|
||||||
|
using LawCompanyContracts.BindingModels;
|
||||||
using LawCompanyContracts.BusinessLogicContracts;
|
using LawCompanyContracts.BusinessLogicContracts;
|
||||||
using LawCompanyContracts.SearchModels;
|
using LawCompanyContracts.SearchModels;
|
||||||
using LawCompanyContracts.StoragesContracts;
|
using LawCompanyContracts.StoragesContracts;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using LawCompanyDataModels.Models;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace LawCompanyBusinessLogic.BusinessLogics
|
namespace LawCompanyBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ConsultationLogic : IConsultationLogic
|
public class ConsultationLogic : IConsultationLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IConsultationStorage _consultationStorage;
|
private readonly IConsultationStorage _consultationStorage;
|
||||||
|
|
||||||
public ConsultationLogic(ILogger<ConsultationLogic> logger, IConsultationStorage consultationStorage)
|
public ConsultationLogic(ILogger<ConsultationLogic> logger, IConsultationStorage consultationStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_consultationStorage = consultationStorage;
|
_consultationStorage = consultationStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(ConsultationBindingModel model)
|
public bool Create(ConsultationBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_consultationStorage.Insert(model) == null)
|
if (_consultationStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(ConsultationBindingModel model)
|
public bool Delete(ConsultationBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_consultationStorage.Delete(model) == null)
|
if (_consultationStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsultationViewModel? ReadElement(ConsultationSearchModel model)
|
public ConsultationViewModel? ReadElement(ConsultationSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. ConsultationDate:{ConsultationDate}. Id:{Id}", model.ConsultationDate, model.Id);
|
_logger.LogInformation("ReadElement. ConsultationDate:{ConsultationDate}. Id:{Id}", model.ConsultationDate, model.Id);
|
||||||
var element = _consultationStorage.GetElement(model);
|
var element = _consultationStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ConsultationViewModel>? ReadList(ConsultationSearchModel? model)
|
public List<ConsultationViewModel>? ReadList(ConsultationSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ConsultationDate:{ConsultationDate}.Id:{Id}", model?.ConsultationDate, model?.Id);
|
_logger.LogInformation("ReadList. ConsultationDate:{ConsultationDate}.Id:{Id}", model?.ConsultationDate, model?.Id);
|
||||||
var list = model == null ? _consultationStorage.GetFullList() : _consultationStorage.GetFilteredList(model);
|
var list = model == null ? _consultationStorage.GetFullList() : _consultationStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(ConsultationBindingModel model)
|
public bool Update(ConsultationBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_consultationStorage.Update(model) == null)
|
if (_consultationStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool AddLawyerToConsultation(ConsultationSearchModel model, ILawyerModel lawyer)
|
public bool AddLawyerToConsultation(ConsultationSearchModel model, ILawyerModel lawyer)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
var element = _consultationStorage.GetElement(model);
|
var element = _consultationStorage.GetElement(model);
|
||||||
|
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
element.ConsultationLawyers[lawyer.Id] = lawyer;
|
element.ConsultationLawyers[lawyer.Id] = lawyer;
|
||||||
|
|
||||||
_consultationStorage.Update(new()
|
_consultationStorage.Update(new()
|
||||||
{
|
{
|
||||||
Id = element.Id,
|
Id = element.Id,
|
||||||
Cost = element.Cost,
|
Cost = element.Cost,
|
||||||
ConsultationDate = element.ConsultationDate,
|
ConsultationDate = element.ConsultationDate,
|
||||||
CaseId = element.CaseId,
|
CaseId = element.CaseId,
|
||||||
ConsultationLawyers = element.ConsultationLawyers,
|
ConsultationLawyers = element.ConsultationLawyers,
|
||||||
GuarantorId = element.GuarantorId,
|
GuarantorId = element.GuarantorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(ConsultationBindingModel model, bool withParams = true)
|
private void CheckModel(ConsultationBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (!withParams)
|
if (!withParams)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty((model.ConsultationDate).ToString()))
|
if (string.IsNullOrEmpty((model.ConsultationDate).ToString()))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Не поставлено время", nameof(model.ConsultationDate));
|
throw new ArgumentNullException("Не поставлено время", nameof(model.ConsultationDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Consultation. ConsultationDate:{ConsultationDate}. Id: {Id} ", model.ConsultationDate, model.Id);
|
_logger.LogInformation("Consultation. ConsultationDate:{ConsultationDate}. Id: {Id} ", model.ConsultationDate, model.Id);
|
||||||
var element = _consultationStorage.GetElement(new ConsultationSearchModel
|
var element = _consultationStorage.GetElement(new ConsultationSearchModel
|
||||||
{
|
{
|
||||||
ConsultationDate = model.ConsultationDate
|
ConsultationDate = model.ConsultationDate
|
||||||
|
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("На данное время уже назначена консультация");
|
throw new InvalidOperationException("На данное время уже назначена консультация");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace LawCompanyBusinessLogic.BusinessLogics
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IExecutorStorage _executorStorage;
|
private readonly IExecutorStorage _executorStorage;
|
||||||
|
|
||||||
public ExecutorLogic(ILogger logger, IExecutorStorage executorStorage)
|
public ExecutorLogic(ILogger<ExecutorLogic> logger, IExecutorStorage executorStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_executorStorage = executorStorage;
|
_executorStorage = executorStorage;
|
||||||
@ -119,8 +119,8 @@ namespace LawCompanyBusinessLogic.BusinessLogics
|
|||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Исполнитель с такими данными уже есть");
|
throw new InvalidOperationException("Исполнитель с такими данными уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,115 +7,115 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace LawCompanyBusinessLogic.BusinessLogics
|
namespace LawCompanyBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class GuarantorLogic : IGuarantorLogic
|
public class GuarantorLogic : IGuarantorLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IGuarantorStorage _guarantorStorage;
|
private readonly IGuarantorStorage _guarantorStorage;
|
||||||
|
|
||||||
public GuarantorLogic(ILogger logger, IGuarantorStorage guarantorStorage)
|
public GuarantorLogic(ILogger<GuarantorLogic> logger, IGuarantorStorage guarantorStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_guarantorStorage = guarantorStorage;
|
_guarantorStorage = guarantorStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(GuarantorBindingModel model)
|
public bool Create(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_guarantorStorage.Insert(model) == null)
|
if (_guarantorStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(GuarantorBindingModel model)
|
public bool Update(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_guarantorStorage.Update(model) == null)
|
if (_guarantorStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(GuarantorBindingModel model)
|
public bool Delete(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_guarantorStorage.Delete(model) == null)
|
if (_guarantorStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GuarantorViewModel>? ReadList(GuarantorSearchModel? model)
|
public List<GuarantorViewModel>? ReadList(GuarantorSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. GuarantorName:{GuarantorName}.Id:{Id}", model?.FIO, model?.Id);
|
_logger.LogInformation("ReadList. GuarantorName:{GuarantorName}.Id:{Id}", model?.FIO, model?.Id);
|
||||||
var list = model == null ? _guarantorStorage.GetFullList() : _guarantorStorage.GetFilteredList(model);
|
var list = model == null ? _guarantorStorage.GetFullList() : _guarantorStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? ReadElement(GuarantorSearchModel model)
|
public GuarantorViewModel? ReadElement(GuarantorSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. GuarantorName:{GuarantorName}. Id:{Id}", model.FIO, model.Id);
|
_logger.LogInformation("ReadElement. GuarantorName:{GuarantorName}. Id:{Id}", model.FIO, model.Id);
|
||||||
var element = _guarantorStorage.GetElement(model);
|
var element = _guarantorStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckModel(GuarantorBindingModel model, bool withParams = true)
|
private void CheckModel(GuarantorBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (!withParams)
|
if (!withParams)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.FIO))
|
if (string.IsNullOrEmpty(model.FIO))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет имени поручителя", nameof(model.FIO));
|
throw new ArgumentNullException("Нет имени поручителя", nameof(model.FIO));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Email))
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет e-mail поручителя", nameof(model.Email));
|
throw new ArgumentNullException("Нет e-mail поручителя", nameof(model.Email));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Password))
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет пароля поручителя", nameof(model.Password));
|
throw new ArgumentNullException("Нет пароля поручителя", nameof(model.Password));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Guarantor. GuarantorName:{FIO}. E-mail:{Email}. Password: {Password} Id: {Id} ", model.FIO, model.Email, model.Password, model.Id);
|
_logger.LogInformation("Guarantor. GuarantorName:{FIO}. E-mail:{Email}. Password: {Password} Id: {Id} ", model.FIO, model.Email, model.Password, model.Id);
|
||||||
var element = _guarantorStorage.GetElement(new GuarantorSearchModel
|
var element = _guarantorStorage.GetElement(new GuarantorSearchModel
|
||||||
{
|
{
|
||||||
FIO = model.FIO,
|
FIO = model.FIO,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
Password = model.Password,
|
Password = model.Password,
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Поручитель с такими данными уже есть");
|
throw new InvalidOperationException("Поручитель с такими данными уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,148 +7,147 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace LawCompanyBusinessLogic.BusinessLogics
|
namespace LawCompanyBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class LawyerLogic : ILawyerLogic
|
public class LawyerLogic : ILawyerLogic
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ILawyerStorage _lawyerStorage;
|
private readonly ILawyerStorage _lawyerStorage;
|
||||||
|
|
||||||
public LawyerLogic(ILogger<LawyerLogic> logger, ILawyerStorage lawyerStorage)
|
public LawyerLogic(ILogger<LawyerLogic> logger, ILawyerStorage lawyerStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_lawyerStorage = lawyerStorage;
|
_lawyerStorage = lawyerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(LawyerBindingModel model)
|
public bool Create(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_lawyerStorage.Insert(model) == null)
|
if (_lawyerStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete(LawyerBindingModel model)
|
public bool Delete(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
if (_lawyerStorage.Delete(model) == null)
|
if (_lawyerStorage.Delete(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LawyerViewModel>? ReadHearingElementList(HearingSearchModel? model)
|
public List<LawyerViewModel>? ReadHearingElementList(HearingSearchModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var list = _lawyerStorage.GetLawyerHearingList(model);
|
var list = _lawyerStorage.GetLawyerHearingList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LawyerViewModel>? ReadConsultationElementList(ConsultationSearchModel? model)
|
public List<LawyerViewModel>? ReadConsultationElementList(ConsultationSearchModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var list = _lawyerStorage.GetLawyerConsultationList(model);
|
var list = _lawyerStorage.GetLawyerConsultationList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LawyerViewModel? ReadElement(LawyerSearchModel model)
|
public LawyerViewModel? ReadElement(LawyerSearchModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement. LawyerName:{FIO}. Id:{Id}", model.FIO, model.Id);
|
_logger.LogInformation("ReadElement. LawyerName:{FIO}. Id:{Id}", model.FIO, model.Id);
|
||||||
var element = _lawyerStorage.GetElement(model);
|
var element = _lawyerStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadElement element not found");
|
_logger.LogWarning("ReadElement element not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LawyerViewModel>? ReadList(LawyerSearchModel? model)
|
public List<LawyerViewModel>? ReadList(LawyerSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. LawyerName:{LawyerName}.Id:{Id}", model?.FIO, model?.Id);
|
_logger.LogInformation("ReadList. LawyerName:{LawyerName}.Id:{Id}", model?.FIO, model?.Id);
|
||||||
var list = model == null ? _lawyerStorage.GetFullList() : _lawyerStorage.GetFilteredList(model);
|
var list = model == null ? _lawyerStorage.GetFullList() : _lawyerStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(LawyerBindingModel model)
|
public bool Update(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_lawyerStorage.Update(model) == null)
|
if (_lawyerStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void CheckModel(LawyerBindingModel model, bool withParams = true)
|
private void CheckModel(LawyerBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (!withParams)
|
if (!withParams)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.FIO))
|
if (string.IsNullOrEmpty(model.FIO))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет имени юриста", nameof(model.FIO));
|
throw new ArgumentNullException("Нет имени юриста", nameof(model.FIO));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Phone))
|
if (string.IsNullOrEmpty(model.Phone))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет телефона юриста", nameof(model.Phone));
|
throw new ArgumentNullException("Нет телефона юриста", nameof(model.Phone));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Email))
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет e-mail юриста", nameof(model.Email));
|
throw new ArgumentNullException("Нет e-mail юриста", nameof(model.Email));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Lawyer. LawyerName:{FIO}. Phone: {Phone}. E-mail:{Email}. Id: {Id} ", model.FIO, model.Phone, model.Email, model.Id);
|
_logger.LogInformation("Lawyer. LawyerName:{FIO}. Phone: {Phone}. E-mail:{Email}. Id: {Id} ", model.FIO, model.Phone, model.Email, model.Id);
|
||||||
var element = _lawyerStorage.GetElement(new LawyerSearchModel
|
var element = _lawyerStorage.GetElement(new LawyerSearchModel
|
||||||
{
|
{
|
||||||
FIO = model.FIO,
|
FIO = model.FIO,
|
||||||
Phone = model.Phone,
|
Phone = model.Phone,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
GuarantorId = model.GuarantorId,
|
|
||||||
|
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Юрист с такими данными уже есть");
|
throw new InvalidOperationException("Юрист с такими данными уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace LawCompanyContracts.BindingModels
|
namespace LawCompanyContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class ConsultationBindingModel : IConsultationModel
|
public class ConsultationBindingModel : IConsultationModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public DateTime ConsultationDate { get; set; }
|
public DateTime ConsultationDate { get; set; }
|
||||||
public int CaseId { get; set; }
|
public int CaseId { get; set; }
|
||||||
public int GuarantorId { get; set; }
|
public int GuarantorId { get; set; }
|
||||||
public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
|
public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace LawCompanyContracts.BindingModels
|
namespace LawCompanyContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class GuarantorBindingModel : IGuarantorModel
|
public class GuarantorBindingModel : IGuarantorModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace LawCompanyContracts.BindingModels
|
namespace LawCompanyContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class LawyerBindingModel : ILawyerModel
|
public class LawyerBindingModel : ILawyerModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
public string Phone { get; set; } = string.Empty;
|
public string Phone { get; set; } = string.Empty;
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
public int? GuarantorId { get; set; }
|
public int? GuarantorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
using LawCompanyContracts.BindingModels;
|
using LawCompanyDataModels.Models;
|
||||||
using LawCompanyDataModels.Models;
|
using LawCompanyContracts.BindingModels;
|
||||||
using LawCompanyContracts.SearchModels;
|
using LawCompanyContracts.SearchModels;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
|
|
||||||
namespace LawCompanyContracts.BusinessLogicContracts
|
namespace LawCompanyContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
public interface IConsultationLogic
|
public interface IConsultationLogic
|
||||||
{
|
{
|
||||||
List<ConsultationViewModel>? ReadList(ConsultationSearchModel? model);
|
List<ConsultationViewModel>? ReadList(ConsultationSearchModel? model);
|
||||||
ConsultationViewModel? ReadElement(ConsultationSearchModel model);
|
ConsultationViewModel? ReadElement(ConsultationSearchModel model);
|
||||||
bool Create(ConsultationBindingModel model);
|
bool Create(ConsultationBindingModel model);
|
||||||
bool Update(ConsultationBindingModel model);
|
bool Update(ConsultationBindingModel model);
|
||||||
bool Delete(ConsultationBindingModel model);
|
bool Delete(ConsultationBindingModel model);
|
||||||
bool AddLawyerToConsultation(ConsultationSearchModel model, ILawyerModel lawyer);
|
bool AddLawyerToConsultation(ConsultationSearchModel model, ILawyerModel lawyer);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,15 @@
|
|||||||
using LawCompanyContracts.BindingModels;
|
using LawCompanyContracts.BindingModels;
|
||||||
using LawCompanyContracts.SearchModels;
|
using LawCompanyContracts.SearchModels;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.BusinessLogicContracts
|
namespace LawCompanyContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
public interface IGuarantorLogic
|
public interface IGuarantorLogic
|
||||||
{
|
{
|
||||||
List<GuarantorViewModel>? ReadList(GuarantorSearchModel? model);
|
List<GuarantorViewModel>? ReadList(GuarantorSearchModel? model);
|
||||||
GuarantorViewModel? ReadElement(GuarantorSearchModel model);
|
GuarantorViewModel? ReadElement(GuarantorSearchModel model);
|
||||||
bool Create(GuarantorBindingModel model);
|
bool Create(GuarantorBindingModel model);
|
||||||
bool Update(GuarantorBindingModel model);
|
bool Update(GuarantorBindingModel model);
|
||||||
bool Delete(GuarantorBindingModel model);
|
bool Delete(GuarantorBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,17 @@
|
|||||||
using LawCompanyContracts.BindingModels;
|
using LawCompanyDataModels.Models;
|
||||||
using LawCompanyDataModels.Models;
|
using LawCompanyContracts.BindingModels;
|
||||||
using LawCompanyContracts.SearchModels;
|
using LawCompanyContracts.SearchModels;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.BusinessLogicContracts
|
namespace LawCompanyContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
public interface IHearingLogic
|
public interface IHearingLogic
|
||||||
{
|
{
|
||||||
List<HearingViewModel>? ReadList(HearingSearchModel? model);
|
List<HearingViewModel>? ReadList(HearingSearchModel? model);
|
||||||
HearingViewModel? ReadElement(HearingSearchModel model);
|
HearingViewModel? ReadElement(HearingSearchModel model);
|
||||||
bool Create(HearingBindingModel model);
|
bool Create(HearingBindingModel model);
|
||||||
bool Update(HearingBindingModel model);
|
bool Update(HearingBindingModel model);
|
||||||
bool Delete(HearingBindingModel model);
|
bool Delete(HearingBindingModel model);
|
||||||
bool AddLawyerToHearing(HearingSearchModel model, ILawyerModel client);
|
bool AddLawyerToHearing(HearingSearchModel model, ILawyerModel client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,17 @@
|
|||||||
using LawCompanyContracts.BindingModels;
|
using LawCompanyContracts.BindingModels;
|
||||||
using LawCompanyContracts.SearchModels;
|
using LawCompanyContracts.SearchModels;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.BusinessLogicContracts
|
namespace LawCompanyContracts.BusinessLogicContracts
|
||||||
{
|
{
|
||||||
public interface ILawyerLogic
|
public interface ILawyerLogic
|
||||||
{
|
{
|
||||||
List<LawyerViewModel>? ReadHearingElementList(HearingSearchModel? model);
|
List<LawyerViewModel>? ReadHearingElementList(HearingSearchModel? model);
|
||||||
List<LawyerViewModel>? ReadConsultationElementList(ConsultationSearchModel? model);
|
List<LawyerViewModel>? ReadConsultationElementList(ConsultationSearchModel? model);
|
||||||
List<LawyerViewModel>? ReadList(LawyerSearchModel? model);
|
List<LawyerViewModel>? ReadList(LawyerSearchModel? model);
|
||||||
LawyerViewModel? ReadElement(LawyerSearchModel model);
|
LawyerViewModel? ReadElement(LawyerSearchModel model);
|
||||||
bool Create(LawyerBindingModel model);
|
bool Create(LawyerBindingModel model);
|
||||||
bool Update(LawyerBindingModel model);
|
bool Update(LawyerBindingModel model);
|
||||||
bool Delete(LawyerBindingModel model);
|
bool Delete(LawyerBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
namespace LawCompanyContracts.SearchModels
|
namespace LawCompanyContracts.SearchModels
|
||||||
{
|
{
|
||||||
public class ConsultationSearchModel
|
public class ConsultationSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public double? Cost { get; set; }
|
public double? Cost { get; set; }
|
||||||
public DateTime? ConsultationDate { get; set; }
|
public DateTime? ConsultationDate { get; set; }
|
||||||
public int? CaseId { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public int? GuarantorId { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
}
|
public int? CaseId { get; set; }
|
||||||
|
public int? GuarantorId { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
using System;
|
namespace LawCompanyContracts.SearchModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.SearchModels
|
|
||||||
{
|
{
|
||||||
public class GuarantorSearchModel
|
public class GuarantorSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? FIO { get; set; }
|
public string? FIO { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
using System;
|
namespace LawCompanyContracts.SearchModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.SearchModels
|
|
||||||
{
|
{
|
||||||
public class HearingSearchModel
|
public class HearingSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public DateTime? HearingDate { get; set; }
|
public DateTime? HearingDate { get; set; }
|
||||||
public int? GuarantorId { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
}
|
public DateTime? DateTo { get; set; }
|
||||||
|
public int? GuarantorId { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
using System;
|
namespace LawCompanyContracts.SearchModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.SearchModels
|
|
||||||
{
|
{
|
||||||
public class LawyerSearchModel
|
public class LawyerSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? FIO { get; set; }
|
public string? FIO { get; set; }
|
||||||
public string? Phone { get; set; }
|
public string? Phone { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public int? GuarantorId { get; set; }
|
public int? GuarantorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace LawCompanyContracts.SearchModels
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyContracts.SearchModels
|
|
||||||
{
|
{
|
||||||
public class VisitSearchModel
|
public class VisitSearchModel
|
||||||
{
|
{
|
||||||
|
@ -4,13 +4,13 @@ using LawCompanyContracts.ViewModels;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.StoragesContracts
|
namespace LawCompanyContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface ICaseStorage
|
public interface ICaseStorage
|
||||||
{
|
{
|
||||||
List<CaseViewModel> GetFullList();
|
List<CaseViewModel> GetFullList();
|
||||||
List<CaseViewModel> GetFilteredList(CaseSearchModel model);
|
List<CaseViewModel> GetFilteredList(CaseSearchModel model);
|
||||||
CaseViewModel? GetElement(CaseSearchModel model);
|
CaseViewModel? GetElement(CaseSearchModel model);
|
||||||
CaseViewModel? Insert(CaseBindingModel model);
|
CaseViewModel? Insert(CaseBindingModel model);
|
||||||
CaseViewModel? Update(CaseBindingModel model);
|
CaseViewModel? Update(CaseBindingModel model);
|
||||||
CaseViewModel? Delete(CaseBindingModel model);
|
CaseViewModel? Delete(CaseBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ using LawCompanyContracts.ViewModels;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.StoragesContracts
|
namespace LawCompanyContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IConsultationStorage
|
public interface IConsultationStorage
|
||||||
{
|
{
|
||||||
List<ConsultationViewModel> GetFullList();
|
List<ConsultationViewModel> GetFullList();
|
||||||
List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model);
|
List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model);
|
||||||
ConsultationViewModel? GetElement(ConsultationSearchModel model);
|
ConsultationViewModel? GetElement(ConsultationSearchModel model);
|
||||||
ConsultationViewModel? Insert(ConsultationBindingModel model);
|
ConsultationViewModel? Insert(ConsultationBindingModel model);
|
||||||
ConsultationViewModel? Update(ConsultationBindingModel model);
|
ConsultationViewModel? Update(ConsultationBindingModel model);
|
||||||
ConsultationViewModel? Delete(ConsultationBindingModel model);
|
ConsultationViewModel? Delete(ConsultationBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,13 +4,13 @@ using LawCompanyContracts.ViewModels;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.StoragesContracts
|
namespace LawCompanyContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public interface IGuarantorStorage
|
public interface IGuarantorStorage
|
||||||
{
|
{
|
||||||
List<GuarantorViewModel> GetFullList();
|
List<GuarantorViewModel> GetFullList();
|
||||||
List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model);
|
List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model);
|
||||||
GuarantorViewModel? GetElement(GuarantorSearchModel model);
|
GuarantorViewModel? GetElement(GuarantorSearchModel model);
|
||||||
GuarantorViewModel? Insert(GuarantorBindingModel model);
|
GuarantorViewModel? Insert(GuarantorBindingModel model);
|
||||||
GuarantorViewModel? Update(GuarantorBindingModel model);
|
GuarantorViewModel? Update(GuarantorBindingModel model);
|
||||||
GuarantorViewModel? Delete(GuarantorBindingModel model);
|
GuarantorViewModel? Delete(GuarantorBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,13 +4,13 @@ using LawCompanyContracts.ViewModels;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.StoragesContracts
|
namespace LawCompanyContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public class IHearingStorage
|
public interface IHearingStorage
|
||||||
{
|
{
|
||||||
List<HearingViewModel> GetFullList();
|
List<HearingViewModel> GetFullList();
|
||||||
List<HearingViewModel> GetFilteredList(HearingSearchModel model);
|
List<HearingViewModel> GetFilteredList(HearingSearchModel model);
|
||||||
HearingViewModel? GetElement(HearingSearchModel model);
|
HearingViewModel? GetElement(HearingSearchModel model);
|
||||||
HearingViewModel? Insert(HearingBindingModel model);
|
HearingViewModel? Insert(HearingBindingModel model);
|
||||||
HearingViewModel? Update(HearingBindingModel model);
|
HearingViewModel? Update(HearingBindingModel model);
|
||||||
HearingViewModel? Delete(HearingBindingModel model);
|
HearingViewModel? Delete(HearingBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,15 +4,15 @@ using LawCompanyContracts.ViewModels;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.StoragesContracts
|
namespace LawCompanyContracts.StoragesContracts
|
||||||
{
|
{
|
||||||
public class ILawyerStorage
|
public interface ILawyerStorage
|
||||||
{
|
{
|
||||||
List<LawyerViewModel> GetFullList();
|
List<LawyerViewModel> GetFullList();
|
||||||
List<LawyerViewModel> GetFilteredList(LawyerSearchModel model);
|
List<LawyerViewModel> GetFilteredList(LawyerSearchModel model);
|
||||||
List<LawyerViewModel> GetLawyerConsultationList(ConsultationSearchModel model);
|
List<LawyerViewModel> GetLawyerConsultationList(ConsultationSearchModel model);
|
||||||
List<LawyerViewModel> GetLawyerHearingList(HearingSearchModel model);
|
List<LawyerViewModel> GetLawyerHearingList(HearingSearchModel model);
|
||||||
LawyerViewModel? GetElement(LawyerSearchModel model);
|
LawyerViewModel? GetElement(LawyerSearchModel model);
|
||||||
LawyerViewModel? Insert(LawyerBindingModel model);
|
LawyerViewModel? Insert(LawyerBindingModel model);
|
||||||
LawyerViewModel? Update(LawyerBindingModel model);
|
LawyerViewModel? Update(LawyerBindingModel model);
|
||||||
LawyerViewModel? Delete(LawyerBindingModel model);
|
LawyerViewModel? Delete(LawyerBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,20 +3,18 @@ using System.ComponentModel;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.ViewModels
|
namespace LawCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ConsultationViewModel : IConsultationModel
|
public class ConsultationViewModel : IConsultationModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер консультации")]
|
[DisplayName("Номер консультации")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Цена консультации")]
|
[DisplayName("Цена консультации")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
[DisplayName("Дата консультации")]
|
[DisplayName("Дата консультации")]
|
||||||
public DateTime ConsultationDate { get; set; }
|
public DateTime ConsultationDate { get; set; }
|
||||||
[DisplayName("Дело")]
|
[DisplayName("Дело")]
|
||||||
public string CaseName { get; set; } = string.Empty;
|
public string CaseName { get; set; } = string.Empty;
|
||||||
public int CaseId { get; set; }
|
public int CaseId { get; set; }
|
||||||
[DisplayName("Имя поручителя")]
|
public int GuarantorId { get; set; }
|
||||||
public string GuarantorName { get; set; } = string.Empty;
|
public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
|
||||||
public int GuarantorId { get; set; }
|
}
|
||||||
public Dictionary<int, ILawyerModel> ConsultationLawyers { get; set; } = new();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,14 +3,14 @@ using System.ComponentModel;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.ViewModels
|
namespace LawCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class GuarantorViewModel : IGuarantorModel
|
public class GuarantorViewModel : IGuarantorModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Имя поручителя")]
|
[DisplayName("Имя поручителя")]
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
[DisplayName("E-mail поручителя")]
|
[DisplayName("E-mail поручителя")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
[DisplayName("Пароль поручителя")]
|
[DisplayName("Пароль поручителя")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,16 +3,16 @@ using System.ComponentModel;
|
|||||||
|
|
||||||
namespace LawCompanyContracts.ViewModels
|
namespace LawCompanyContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class LawyerViewModel : ILawyerModel
|
public class LawyerViewModel : ILawyerModel
|
||||||
{
|
{
|
||||||
[DisplayName("Номер юриста")]
|
[DisplayName("Номер юриста")]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Имя юриста")]
|
[DisplayName("Имя юриста")]
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Телефон юриста")]
|
[DisplayName("Телефон юриста")]
|
||||||
public string Phone { get; set; } = string.Empty;
|
public string Phone { get; set; } = string.Empty;
|
||||||
[DisplayName("E-mail юриста")]
|
[DisplayName("E-mail юриста")]
|
||||||
public string Email { get; set; } = string.Empty;
|
public string Email { get; set; } = string.Empty;
|
||||||
public int? GuarantorId { get; set; }
|
public int? GuarantorId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,101 +3,96 @@ using LawCompanyContracts.SearchModels;
|
|||||||
using LawCompanyContracts.StoragesContracts;
|
using LawCompanyContracts.StoragesContracts;
|
||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using LawCompanyDatabaseImplement.Models;
|
using LawCompanyDatabaseImplement.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LawCompanyDatabaseImplement.Implements
|
namespace LawCompanyDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class GuarantorStorage : IGuarantorStorage
|
public class GuarantorStorage : IGuarantorStorage
|
||||||
{
|
{
|
||||||
public List<GuarantorViewModel> GetFullList()
|
public List<GuarantorViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Guarantors
|
return context.Guarantors
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model)
|
public List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
||||||
&& string.IsNullOrEmpty(model.Password))
|
&& string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(model.Email))
|
if (!string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Guarantors
|
return context.Guarantors
|
||||||
.Where(x => x.Email.Equals(model.Email))
|
.Where(x => x.Email.Equals(model.Email))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Guarantors
|
return context.Guarantors
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? GetElement(GuarantorSearchModel model)
|
public GuarantorViewModel? GetElement(GuarantorSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && string.IsNullOrEmpty(model.FIO)
|
||||||
&& string.IsNullOrEmpty(model.Password))
|
&& string.IsNullOrEmpty(model.Password))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
|
|
||||||
return context.Guarantors
|
return context.Guarantors
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email)
|
.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))
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? Insert(GuarantorBindingModel model)
|
public GuarantorViewModel? Insert(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var newGuarantor = Guarantor.Create(model);
|
var newGuarantor = Guarantor.Create(context, model);
|
||||||
if (newGuarantor == null)
|
if (newGuarantor == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
context.Guarantors.Add(newGuarantor);
|
context.Guarantors.Add(newGuarantor);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newGuarantor.GetViewModel;
|
return newGuarantor.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? Update(GuarantorBindingModel model)
|
public GuarantorViewModel? Update(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var executor = context.Guarantors.FirstOrDefault(x => x.Id == model.Id);
|
var executor = context.Guarantors.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (executor == null)
|
if (executor == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
executor.Update(model);
|
executor.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return executor.GetViewModel;
|
return executor.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? Delete(GuarantorBindingModel model)
|
public GuarantorViewModel? Delete(GuarantorBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var element = context.Guarantors.FirstOrDefault(rec => rec.Id == model.Id);
|
var element = context.Guarantors.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Guarantors.Remove(element);
|
context.Guarantors.Remove(element);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,105 +6,105 @@ using LawCompanyDatabaseImplement.Models;
|
|||||||
|
|
||||||
namespace LawCompanyDatabaseImplement.Implements
|
namespace LawCompanyDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
public class LawyerStorage : ILawyerStorage
|
public class LawyerStorage : ILawyerStorage
|
||||||
{
|
{
|
||||||
public List<LawyerViewModel> GetFullList()
|
public List<LawyerViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Lawyers
|
return context.Lawyers
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<LawyerViewModel> GetFilteredList(LawyerSearchModel model)
|
public List<LawyerViewModel> GetFilteredList(LawyerSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && !model.GuarantorId.HasValue && string.IsNullOrEmpty(model.FIO))
|
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && !model.GuarantorId.HasValue && string.IsNullOrEmpty(model.FIO))
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(model.Email))
|
if (!string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Lawyers
|
return context.Lawyers
|
||||||
.Where(x => x.Email.Equals(model.Email))
|
.Where(x => x.Email.Equals(model.Email))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else if (model.GuarantorId.HasValue)
|
else if (model.GuarantorId.HasValue)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Lawyers
|
return context.Lawyers
|
||||||
.Where(x => x.GuarantorId.Equals(model.GuarantorId))
|
.Where(x => x.GuarantorId.Equals(model.GuarantorId))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Lawyers
|
return context.Lawyers
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public LawyerViewModel? GetElement(LawyerSearchModel model)
|
public LawyerViewModel? GetElement(LawyerSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && !model.GuarantorId.HasValue
|
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue && !model.GuarantorId.HasValue
|
||||||
&& string.IsNullOrEmpty(model.FIO))
|
&& string.IsNullOrEmpty(model.FIO))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.Lawyers
|
return context.Lawyers
|
||||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (model.GuarantorId.HasValue && x.GuarantorId == model.GuarantorId))
|
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (model.GuarantorId.HasValue && x.GuarantorId == model.GuarantorId))
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
public LawyerViewModel? Insert(LawyerBindingModel model)
|
public LawyerViewModel? Insert(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var newLawyer = Lawyer.Create(model);
|
var newLawyer = Lawyer.Create(context, model);
|
||||||
if (newLawyer == null)
|
if (newLawyer == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
context.Lawyers.Add(newLawyer);
|
context.Lawyers.Add(newLawyer);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newLawyer.GetViewModel;
|
return newLawyer.GetViewModel;
|
||||||
}
|
}
|
||||||
public LawyerViewModel? Update(LawyerBindingModel model)
|
public LawyerViewModel? Update(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var lawyer = context.Lawyers.FirstOrDefault(x => x.Id == model.Id);
|
var lawyer = context.Lawyers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (lawyer == null)
|
if (lawyer == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
lawyer.Update(model);
|
lawyer.Update(model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return lawyer.GetViewModel;
|
return lawyer.GetViewModel;
|
||||||
}
|
}
|
||||||
public LawyerViewModel? Delete(LawyerBindingModel model)
|
public LawyerViewModel? Delete(LawyerBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
var element = context.Lawyers.FirstOrDefault(rec => rec.Id == model.Id);
|
var element = context.Lawyers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
context.Lawyers.Remove(element);
|
context.Lawyers.Remove(element);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return element.GetViewModel;
|
return element.GetViewModel;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public List<LawyerViewModel> GetLawyerHearingList(HearingSearchModel model)
|
public List<LawyerViewModel> GetLawyerHearingList(HearingSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.HearingLawyers.Where(x => x.HearingId == model.Id).Select(x => x.Lawyer.GetViewModel).ToList();
|
return context.HearingLawyers.Where(x => x.HearingId == model.Id).Select(x => x.Lawyer.GetViewModel).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
public List<LawyerViewModel> GetLawyerConsultationList(ConsultationSearchModel model)
|
public List<LawyerViewModel> GetLawyerConsultationList(ConsultationSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new LawCompanyDatabase();
|
using var context = new LawCompanyDatabase();
|
||||||
return context.ConsultationLawyers.Where(x => x.ConsultationId == model.Id).Select(x => x.Lawyer.GetViewModel).ToList();
|
return context.ConsultationLawyers.Where(x => x.ConsultationId == model.Id).Select(x => x.Lawyer.GetViewModel).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ using LawCompanyContracts.BindingModels;
|
|||||||
using LawCompanyContracts.ViewModels;
|
using LawCompanyContracts.ViewModels;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using LawFirmDatabaseImplement.Models;
|
using LawCompanyDatabaseImplement.Models;
|
||||||
|
|
||||||
namespace LawCompanyDatabaseImplement.Models
|
namespace LawCompanyDatabaseImplement.Models
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user