Бизнес-логика
This commit is contained in:
parent
2df57b4647
commit
dd1c6897fc
159
Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs
Normal file
159
Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs
Normal file
@ -0,0 +1,159 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ConferenceLogic : IConferenceLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IConferenceStorage _conferenceStorage;
|
||||
|
||||
public ConferenceLogic(ILogger<ConferenceLogic> logger, IConferenceStorage conferenceStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_conferenceStorage = conferenceStorage;
|
||||
}
|
||||
|
||||
public List<ConferenceViewModel>? ReadList(ConferenceSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ConferenceName:{ConferenceName}.Id:{ Id}", model?.ConferenceName, model?.Id);
|
||||
|
||||
var list = model == null ? _conferenceStorage.GetFullList() : _conferenceStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public ConferenceViewModel? ReadElement(ConferenceSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ConferenceName:{ConferenceName}.Id:{Id}", model.ConferenceName, model.Id);
|
||||
|
||||
var element = _conferenceStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool AddMemberToConference(ConferenceSearchModel model, IMemberModel member)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMemberToConference. ConferenceName:{ConferenceName}.Id:{ Id}", model.ConferenceName, model.Id);
|
||||
var element = _conferenceStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddMemberToConference element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMemberToConference find. Id:{Id}", element.Id);
|
||||
|
||||
element.ConferenceMembers[member.Id] = member;
|
||||
|
||||
_conferenceStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
ConferenceName = element.ConferenceName,
|
||||
StartDate = element.StartDate,
|
||||
OrganiserId = element.OrganiserId,
|
||||
ConferenceMembers = element.ConferenceMembers,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.ConferenceMembers = new();
|
||||
|
||||
var result = _conferenceStorage.Insert(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_conferenceStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConferenceBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
var result = _conferenceStorage.Delete(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ConferenceBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ConferenceName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия конференции", nameof(model.ConferenceName));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Conference. ConferenceName:{ConferenceName}.StartDate:{ StartDate}. Id: { Id}", model.ConferenceName, model.StartDate, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
174
Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs
Normal file
174
Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs
Normal file
@ -0,0 +1,174 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using HotelDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MealPlanLogic : IMealPlanLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMealPlanStorage _mealPlanStorage;
|
||||
|
||||
public MealPlanLogic(ILogger<MealPlanLogic> logger, IMealPlanStorage mealPlanStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
}
|
||||
|
||||
public List<MealPlanViewModel>? ReadList(MealPlanSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.MealPlanName, model?.Id);
|
||||
|
||||
var list = model == null ? _mealPlanStorage.GetFullList() : _mealPlanStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public MealPlanViewModel? ReadElement(MealPlanSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.MealPlanName, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool AddMemberToMealPlan(MealPlanSearchModel model, IMemberModel member)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMemberToMealPlan. MealPlanName:{MealPlanName}.Id:{ Id}", model.MealPlanName, model.Id);
|
||||
var element = _mealPlanStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddMemberToMealPlan element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddMemberToMealPlan find. Id:{Id}", element.Id);
|
||||
|
||||
element.MealPlanMembers[member.Id] = member;
|
||||
|
||||
_mealPlanStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
MealPlanName = element.MealPlanName,
|
||||
MealPlanPrice = element.MealPlanPrice,
|
||||
OrganiserId = element.OrganiserId,
|
||||
MealPlanMembers = element.MealPlanMembers
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
model.MealPlanMembers = new();
|
||||
|
||||
var result = _mealPlanStorage.Insert(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MealPlanBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
var result = _mealPlanStorage.Delete(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MealPlanBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MealPlanName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия плана питания", nameof(model.MealPlanName));
|
||||
}
|
||||
|
||||
if (model.MealPlanPrice < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Стоимость плана питания не может быть меньше 0", nameof(model.MealPlanPrice));
|
||||
}
|
||||
|
||||
_logger.LogInformation("MealPlan. MealPlanName:{MealPlanName}.MealPlanPrice:{ MealPlanPrice}. Id: { Id}", model.MealPlanName, model.MealPlanPrice, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(new MealPlanSearchModel
|
||||
{
|
||||
MealPlanName = model.MealPlanName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("План питания с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
143
Hotel/HotelBusinessLogic/BusinessLogics/MemberLogic.cs
Normal file
143
Hotel/HotelBusinessLogic/BusinessLogics/MemberLogic.cs
Normal file
@ -0,0 +1,143 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MemberLogic : IMemberLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMemberStorage _memberStorage;
|
||||
|
||||
public MemberLogic(ILogger<MemberLogic> logger, IMemberStorage memberStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_memberStorage = memberStorage;
|
||||
}
|
||||
|
||||
public List<MemberViewModel>? ReadList(MemberSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MemberSurname:{MemberSurname}.MemberName:{MemberName}." +
|
||||
"MemberPatronymic:{MemberPatronymic}.Id:{ Id}", model?.MemberSurname, model?.MemberName, model?.MemberPatronymic, model?.Id);
|
||||
|
||||
var list = model == null ? _memberStorage.GetFullList() : _memberStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public MemberViewModel? ReadElement(MemberSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. MemberSurname:{MemberSurname}.MemberName:{MemberName}." +
|
||||
"MemberPatronymic:{MemberPatronymic}.Id:{ Id}", model?.MemberSurname, model?.MemberName, model?.MemberPatronymic, model?.Id);
|
||||
|
||||
var element = _memberStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
var result = _memberStorage.Insert(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_memberStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(MemberBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
var result = _memberStorage.Delete(model);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MemberBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MemberSurname))
|
||||
{
|
||||
throw new ArgumentNullException("Нет фамилии участника", nameof(model.MemberSurname));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MemberName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени участника", nameof(model.MemberName));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MemberPatronymic))
|
||||
{
|
||||
throw new ArgumentNullException("Нет отчества участника", nameof(model.MemberPatronymic));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.MemberPhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Не указан номер телефона участника", nameof(model.MemberPhoneNumber));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. MemberSurname:{MemberSurname}.MemberName:{MemberName}." +
|
||||
"MemberPatronymic:{MemberPatronymic}.MemberPhoneNumber:{MemberPhoneNumber}.Id:{ Id}", model?.MemberSurname, model?.MemberName, model?.MemberPatronymic, model?.MemberPhoneNumber, model?.Id);
|
||||
}
|
||||
}
|
||||
}
|
187
Hotel/HotelBusinessLogic/BusinessLogics/OrganiserLogic.cs
Normal file
187
Hotel/HotelBusinessLogic/BusinessLogics/OrganiserLogic.cs
Normal file
@ -0,0 +1,187 @@
|
||||
using HotelContracts.BindingModels;
|
||||
using HotelContracts.BusinessLogicsContracts;
|
||||
using HotelContracts.SearchModels;
|
||||
using HotelContracts.StoragesContracts;
|
||||
using HotelContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace HotelBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class OrganiserLogic : IOrganiserLogic
|
||||
{
|
||||
private readonly int _loginMaxLength = 50;
|
||||
private readonly int _passwordMaxLength = 50;
|
||||
private readonly int _passwordMinLength = 10;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrganiserStorage _organiserStorage;
|
||||
|
||||
public OrganiserLogic(ILogger<OrganiserLogic> logger, IOrganiserStorage organiserStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_organiserStorage = organiserStorage;
|
||||
}
|
||||
|
||||
public List<OrganiserViewModel>? ReadList(OrganiserSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. OrganiserSurname: {OrganiserSurname}. OrganiserName: {OrganiserName}." +
|
||||
" OrganiserPatronymic: {OrganiserPatronymic}. OrganiserLogin: {OrganiserLogin}. Id: {Id}.", model?.OrganiserSurname, model?.OrganiserName, model?.OrganiserPatronymic, model?.OrganiserLogin, model?.Id);
|
||||
|
||||
var list = model == null ? _organiserStorage.GetFullList() : _organiserStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrganiserViewModel? ReadElement(OrganiserSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. OrganiserSurname: {OrganiserSurname}. OrganiserName: {OrganiserName}." +
|
||||
" OrganiserPatronymic: {OrganiserPatronymic}. OrganiserLogin: {OrganiserLogin}. Id: {Id}.", model?.OrganiserSurname, model?.OrganiserName, model?.OrganiserPatronymic, model?.OrganiserLogin, model?.Id);
|
||||
|
||||
|
||||
var element = _organiserStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(OrganiserBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_organiserStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(OrganiserBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_organiserStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(OrganiserBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
|
||||
if (_organiserStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrganiserBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserSurname))
|
||||
{
|
||||
throw new ArgumentNullException("Нет фамилии организатора", nameof(model.OrganiserSurname));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет имени организатора", nameof(model.OrganiserName));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserPatronymic))
|
||||
{
|
||||
throw new ArgumentNullException("Нет отчества организатора", nameof(model.OrganiserPatronymic));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserLogin))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина организатора", nameof(model.OrganiserLogin));
|
||||
}
|
||||
|
||||
if (model.OrganiserLogin.Length > _loginMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Логин слишком длинный", nameof(model.OrganiserLogin));
|
||||
}
|
||||
|
||||
if (model.OrganiserEmail.Length > _loginMaxLength || !Regex.IsMatch(model.OrganiserEmail, @"([a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+)"))
|
||||
{
|
||||
throw new Exception($"В качестве логина должна быть указана почта и иметь длинну не более {_loginMaxLength} символов");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserPassword))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля организатора", nameof(model.OrganiserPassword));
|
||||
}
|
||||
|
||||
if (model.OrganiserPassword.Length > _passwordMaxLength || model.OrganiserPassword.Length < _passwordMinLength
|
||||
|| !Regex.IsMatch(model.OrganiserPassword, @"^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$"))
|
||||
{
|
||||
throw new Exception($"Пароль длиной от {_passwordMinLength} до {_passwordMaxLength} должен состоять из цифр, букв и небуквенных символов");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserEmail))
|
||||
{
|
||||
throw new ArgumentNullException("Нет почты организатора", nameof(model.OrganiserEmail));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.OrganiserPhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона организатора", nameof(model.OrganiserPhoneNumber));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. OrganiserSurname: {OrganiserSurname}. OrganiserName: {OrganiserName}." +
|
||||
" OrganiserPatronymic: {OrganiserPatronymic}. OrganiserLogin: {OrganiserLogin}. Id: {Id}.", model?.OrganiserSurname, model?.OrganiserName, model?.OrganiserPatronymic, model?.OrganiserLogin, model?.Id);
|
||||
|
||||
var element = _organiserStorage.GetElement(new OrganiserSearchModel
|
||||
{
|
||||
OrganiserEmail = model.OrganiserEmail
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Организатор с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user