Comit3
This commit is contained in:
parent
d7597ea67b
commit
5c6db64994
@ -10,18 +10,18 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
public class AdditionsLogic : IAdditionsLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IAdditionsPlanStorage _mealPlanStorage;
|
||||
private readonly IAdditionsPlanStorage _additionsStorage;
|
||||
|
||||
public AdditionsLogic(ILogger<AdditionsLogic> logger, IAdditionsPlanStorage mealPlanStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_mealPlanStorage = mealPlanStorage;
|
||||
_additionsStorage = mealPlanStorage;
|
||||
}
|
||||
public bool Create(AdditionsBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Insert(model) == null)
|
||||
if (_additionsStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
@ -36,7 +36,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_mealPlanStorage.Delete(model) == null)
|
||||
if (_additionsStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
@ -52,9 +52,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.MealPlanName, model.Id);
|
||||
_logger.LogInformation("ReadElement. MealPlanName:{MealPlanName}.Id:{Id}", model.AdditionsName, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(model);
|
||||
var element = _additionsStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
@ -69,9 +69,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
public List<AdditionsPlanViewModel>? ReadList(AdditionsSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.MealPlanName, model?.Id);
|
||||
_logger.LogInformation("ReadList. MealPlanName:{MealPlanName}.Id:{ Id}", model?.AdditionsName, model?.Id);
|
||||
|
||||
var list = model == null ? _mealPlanStorage.GetFullList() : _mealPlanStorage.GetFilteredList(model);
|
||||
var list = model == null ? _additionsStorage.GetFullList() : _additionsStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
@ -88,7 +88,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_mealPlanStorage.Update(model) == null)
|
||||
if (_additionsStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
@ -121,9 +121,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
_logger.LogInformation("MealPlan. MealPlanName:{MealPlanName}.MealPlanPrice:{ MealPlanPrice}. Id: { Id}", model.MealPlanName, model.MealPlanPrice, model.Id);
|
||||
|
||||
var element = _mealPlanStorage.GetElement(new AdditionsSearchModel
|
||||
var element = _additionsStorage.GetElement(new AdditionsSearchModel
|
||||
{
|
||||
MealPlanName = model.MealPlanName
|
||||
AdditionsName = model.MealPlanName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
|
@ -14,7 +14,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
private readonly int _passwordMinLength = 10;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClercStorage _ClercStorage;
|
||||
private readonly IClercStorage _clercStorage;
|
||||
|
||||
public ClercLogic(ILogger<ClercLogic> logger, IClercStorage clercStorage)
|
||||
{
|
||||
|
@ -19,19 +19,19 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
private readonly int _passwordMinLength = 10;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHeadwaiterStorage _headwaiterStorage;
|
||||
private readonly IClientStorage _clientStorage;
|
||||
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IHeadwaiterStorage headwaiterStorage)
|
||||
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage headwaiterStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_headwaiterStorage = headwaiterStorage;
|
||||
_clientStorage = headwaiterStorage;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_headwaiterStorage.Insert(model) == null)
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
@ -47,7 +47,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
|
||||
if (_headwaiterStorage.Delete(model) == null)
|
||||
if (_clientStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
@ -64,9 +64,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id);
|
||||
_logger.LogInformation("ReadElement. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model.ClientFIO, model.ClientLogin, model.Id);
|
||||
|
||||
var element = _headwaiterStorage.GetElement(model);
|
||||
var element = _clientStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
@ -81,9 +81,9 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model?.HeadwaiterFIO, model?.HeadwaiterLogin, model?.Id);
|
||||
_logger.LogInformation("ReadList. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}.", model?.ClientFIO, model?.ClientLogin, model?.Id);
|
||||
|
||||
var list = model == null ? _headwaiterStorage.GetFullList() : _headwaiterStorage.GetFilteredList(model);
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
@ -100,7 +100,7 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_headwaiterStorage.Update(model) == null)
|
||||
if (_clientStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
@ -120,51 +120,51 @@ namespace BankBusinessLogic.BusinessLogics
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterFIO))
|
||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО метродотеля", nameof(model.HeadwaiterFIO));
|
||||
throw new ArgumentNullException("Нет ФИО метродотеля", nameof(model.ClientFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterLogin))
|
||||
if (string.IsNullOrEmpty(model.ClientLogin))
|
||||
{
|
||||
throw new ArgumentNullException("Нет логина метродотеля", nameof(model.HeadwaiterLogin));
|
||||
throw new ArgumentNullException("Нет логина метродотеля", nameof(model.ClientLogin));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterLogin.Length > _loginMaxLength)
|
||||
if (model.ClientLogin.Length > _loginMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Логин слишком длинный", nameof(model.HeadwaiterLogin));
|
||||
throw new ArgumentNullException("Логин слишком длинный", nameof(model.ClientLogin));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterNumber))
|
||||
if (string.IsNullOrEmpty(model.ClientNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона метродотеля", nameof(model.HeadwaiterNumber));
|
||||
throw new ArgumentNullException("Нет номера телефона метродотеля", nameof(model.ClientNumber));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterEmail))
|
||||
if (string.IsNullOrEmpty(model.ClientEmail))
|
||||
{
|
||||
throw new ArgumentNullException("Нет почты метродотеля", nameof(model.HeadwaiterEmail));
|
||||
throw new ArgumentNullException("Нет почты метродотеля", nameof(model.ClientEmail));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterPassword))
|
||||
if (string.IsNullOrEmpty(model.ClientPassword))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля метродотеля", nameof(model.HeadwaiterPassword));
|
||||
throw new ArgumentNullException("Нет пароля метродотеля", nameof(model.ClientPassword));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterPassword.Length < _passwordMinLength)
|
||||
if (model.ClientPassword.Length < _passwordMinLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком короткий", nameof(model.HeadwaiterPassword));
|
||||
throw new ArgumentNullException("Пароль слишком короткий", nameof(model.ClientPassword));
|
||||
}
|
||||
|
||||
if (model.HeadwaiterPassword.Length > _passwordMaxLength)
|
||||
if (model.ClientPassword.Length > _passwordMaxLength)
|
||||
{
|
||||
throw new ArgumentNullException("Пароль слишком длинный", nameof(model.HeadwaiterPassword));
|
||||
throw new ArgumentNullException("Пароль слишком длинный", nameof(model.ClientPassword));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Headwaiter. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}", model.HeadwaiterFIO, model.HeadwaiterLogin, model.Id);
|
||||
_logger.LogInformation("Headwaiter. HeadwaiterFIO: {HeadwaiterFIO}. HeadwaiterLogin: {HeadwaiterLogin}. Id: {Id}", model.ClientFIO, model.ClientLogin, model.Id);
|
||||
|
||||
var element = _headwaiterStorage.GetElement(new ClientSearchModel
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
HeadwaiterLogin = model.HeadwaiterLogin
|
||||
ClientLogin = model.ClientLogin
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
|
@ -4,15 +4,15 @@ namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ClercBindingModel : IClercModel
|
||||
{
|
||||
public string OrganiserFIO { get; set; } = string.Empty;
|
||||
public string ClercFIO { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserPassword { get; set; } = string.Empty;
|
||||
public string ClercPassword { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserLogin { get; set; } = string.Empty;
|
||||
public string ClercLogin { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserEmail { get; set; } = string.Empty;
|
||||
public string ClercEmail { get; set; } = string.Empty;
|
||||
|
||||
public string OrganiserNumber { get; set; } = string.Empty;
|
||||
public string ClercNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ namespace BankContracts.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public string HeadwaiterFIO { get; set; } = string.Empty;
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterPassword { get; set; } = string.Empty;
|
||||
public string ClientPassword { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterLogin { get; set; } = string.Empty;
|
||||
public string ClientLogin { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterEmail { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
|
||||
public string HeadwaiterNumber { get; set; } = string.Empty;
|
||||
public string ClientNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace BankContracts.BindingModels
|
||||
{
|
||||
public class CreditBindingModel : ICreditModel
|
||||
{
|
||||
public string DinnerName { get; set; } = string.Empty;
|
||||
public string CreditName { get; set; } = string.Empty;
|
||||
|
||||
public double DinnerPrice { get; set; }
|
||||
public double CreditPrice { get; set; }
|
||||
|
||||
public int HeadwaiterId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
public class AdditionsSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? MealPlanName { get; set; }
|
||||
public string? AdditionsName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
public class ClercSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? OrganiserFIO { get; set; }
|
||||
public string? OrganiserLogin { get; set; }
|
||||
public string? OrganiserPassword { get; set; }
|
||||
public string? ClercFIO { get; set; }
|
||||
public string? ClercLogin { get; set; }
|
||||
public string? ClercPassword { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ namespace BankContracts.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public string? HeadwaiterFIO { get; set; }
|
||||
public string? ClientFIO { get; set; }
|
||||
|
||||
public string? HeadwaiterPassword { get; set; }
|
||||
public string? ClientPassword { get; set; }
|
||||
|
||||
public string? HeadwaiterLogin { get; set; }
|
||||
public string? ClientLogin { get; set; }
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ namespace BankContracts.SearchModels
|
||||
{
|
||||
public class CreditSearchModel
|
||||
{
|
||||
public string? DinnerName { get; set; }
|
||||
public string? CreditName { get; set; }
|
||||
public int? Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using BankContracts.ViewModels;
|
||||
|
||||
namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IHeadwaiterStorage
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
|
@ -6,19 +6,19 @@ namespace BankContracts.ViewModels
|
||||
public class ClercViewModel : IClercModel
|
||||
{
|
||||
[DisplayName("ФИО организатора")]
|
||||
public string OrganiserFIO { get; set; } = string.Empty;
|
||||
public string ClercFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль организатора")]
|
||||
public string OrganiserPassword { get; set; } = string.Empty;
|
||||
public string ClercPassword { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин организатора")]
|
||||
public string OrganiserLogin { get; set; } = string.Empty;
|
||||
public string ClercLogin { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Эл. почта организатора")]
|
||||
public string OrganiserEmail { get; set; } = string.Empty;
|
||||
public string ClercEmail { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Номер телефона организатора")]
|
||||
public string OrganiserNumber { get; set; } = string.Empty;
|
||||
public string ClercNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -13,19 +13,19 @@ namespace BankContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО метрдотеля")]
|
||||
public string HeadwaiterFIO { get; set; } = string.Empty;
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль метрдотеля")]
|
||||
public string HeadwaiterPassword { get; set; } = string.Empty;
|
||||
public string ClientPassword { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин метрдотеля")]
|
||||
public string HeadwaiterLogin { get; set; } = string.Empty;
|
||||
public string ClientLogin { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Mail метрдотеля")]
|
||||
public string HeadwaiterEmail { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Телефон метрдотеля")]
|
||||
public string HeadwaiterNumber { get; set; } = string.Empty;
|
||||
public string ClientNumber { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ namespace BankContracts.ViewModels
|
||||
public class CreditViewModel : ICreditModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int HeadwaiterId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[DisplayName("Название обеда")]
|
||||
public string DinnerName { get; set; } = string.Empty;
|
||||
public string CreditName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Цена обеда")]
|
||||
public double DinnerPrice { get; set; }
|
||||
public double CreditPrice { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,14 @@ namespace BankDataBaseImplement
|
||||
}
|
||||
public virtual DbSet<Conference> Conferences { set; get; }
|
||||
public virtual DbSet<Room> Rooms { set; get; }
|
||||
public virtual DbSet<Additions> MealPlans { set; get; }
|
||||
public virtual DbSet<Additions> Additions { set; get; }
|
||||
public virtual DbSet<ConferenceBooking> ConferenceBookings { set; get; }
|
||||
public virtual DbSet<Member> Members { set; get; }
|
||||
public virtual DbSet<Credit> Dinners { set; get; }
|
||||
public virtual DbSet<Clerc> Organisers { set; get; }
|
||||
public virtual DbSet<Client> Headwaiters { set; get; }
|
||||
public virtual DbSet<Credit> Credits { set; get; }
|
||||
public virtual DbSet<Clerc> Clercs { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<ConferenceMember> ConferenceMembers { set; get; }
|
||||
public virtual DbSet<RoomCredit> RoomDinners { set; get; }
|
||||
public virtual DbSet<RoomCredit> RoomCredits { set; get; }
|
||||
public virtual DbSet<AdditionsMember> MealPlanMembers { set; get; }
|
||||
public virtual DbSet<ConferenceBookingDinner> ConferenceBookingDinners { set; get; }
|
||||
|
||||
|
@ -13,12 +13,12 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.MealPlans
|
||||
var element = context.Additions
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.MealPlans.Remove(element);
|
||||
context.Additions.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
@ -36,7 +36,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.MealPlans
|
||||
return context.Additions
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
@ -49,21 +49,21 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
public List<AdditionsPlanViewModel> GetFilteredList(AdditionsSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MealPlanName))
|
||||
if (string.IsNullOrEmpty(model.AdditionsName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.MealPlans
|
||||
return context.Additions
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
.ThenInclude(x => x.Conference)
|
||||
.Include(x => x.Rooms)
|
||||
.Include(x => x.Organiser)
|
||||
.Where(x => x.MealPlanName.Contains(model.MealPlanName))
|
||||
.Where(x => x.MealPlanName.Contains(model.AdditionsName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
public List<AdditionsPlanViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
return context.MealPlans
|
||||
return context.Additions
|
||||
.Include(x => x.Members)
|
||||
.ThenInclude(x => x.Member)
|
||||
.ThenInclude(x => x.ConferenceMember)
|
||||
@ -92,7 +92,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
return null;
|
||||
}
|
||||
|
||||
context.MealPlans.Add(newMealPlan);
|
||||
context.Additions.Add(newMealPlan);
|
||||
context.SaveChanges();
|
||||
return newMealPlan.GetViewModel;
|
||||
}
|
||||
@ -100,7 +100,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
public AdditionsPlanViewModel? Update(AdditionsBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
var mealPlan = context.MealPlans.FirstOrDefault(x => x.Id == model.Id);
|
||||
var mealPlan = context.Additions.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (mealPlan == null)
|
||||
{
|
||||
return null;
|
||||
|
@ -13,11 +13,11 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Organisers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Clercs.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Organisers.Remove(element);
|
||||
context.Clercs.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
@ -31,27 +31,27 @@ namespace BankDataBaseImplement.Implemets
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
return context.Clercs
|
||||
.Include(x => x.Additions)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.OrganiserLogin) && !string.IsNullOrEmpty(model.OrganiserPassword))
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
if (!string.IsNullOrEmpty(model.ClercLogin) && !string.IsNullOrEmpty(model.ClercPassword))
|
||||
return context.Clercs
|
||||
.Include(x => x.Additions)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin) && x.OrganiserPassword.Equals(model.OrganiserPassword))?
|
||||
.FirstOrDefault(x => x.ClercLogin.Equals(model.ClercLogin) && x.ClercPassword.Equals(model.ClercPassword))?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.OrganiserLogin))
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
if (!string.IsNullOrEmpty(model.ClercLogin))
|
||||
return context.Clercs
|
||||
.Include(x => x.Additions)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.FirstOrDefault(x => x.OrganiserLogin.Equals(model.OrganiserLogin))?
|
||||
.FirstOrDefault(x => x.ClercLogin.Equals(model.ClercLogin))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
@ -59,18 +59,18 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
public List<ClercViewModel> GetFilteredList(ClercSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.OrganiserFIO))
|
||||
if (string.IsNullOrEmpty(model.ClercFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Organisers
|
||||
.Include(x => x.MealPlans)
|
||||
return context.Clercs
|
||||
.Include(x => x.Additions)
|
||||
.Include(x => x.Members)
|
||||
.Include(x => x.Conferences)
|
||||
.Where(x => x.OrganiserLogin.Contains(model.OrganiserLogin) && x.OrganiserPassword == model.OrganiserPassword)
|
||||
.Where(x => x.ClercLogin.Contains(model.ClercLogin) && x.ClercPassword == model.ClercPassword)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -79,7 +79,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Organisers
|
||||
return context.Clercs
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -95,7 +95,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
context.Organisers.Add(newOrganiser);
|
||||
context.Clercs.Add(newOrganiser);
|
||||
context.SaveChanges();
|
||||
|
||||
return newOrganiser.GetViewModel;
|
||||
@ -105,7 +105,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var organiser = context.Organisers
|
||||
var organiser = context.Clercs
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (organiser == null)
|
||||
|
@ -12,17 +12,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
public class ClientStorage : IHeadwaiterStorage
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var element = context.Headwaiters.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Headwaiters.Remove(element);
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
@ -36,27 +36,27 @@ namespace BankDataBaseImplement.Implemets
|
||||
using var context = new BankDataBase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Headwaiters
|
||||
return context.Clients
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.HeadwaiterLogin) && !string.IsNullOrEmpty(model.HeadwaiterPassword))
|
||||
return context.Headwaiters
|
||||
if (!string.IsNullOrEmpty(model.ClientLogin) && !string.IsNullOrEmpty(model.ClientPassword))
|
||||
return context.Clients
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin) && x.HeadwaiterPassword.Equals(model.HeadwaiterPassword))?
|
||||
.FirstOrDefault(x => x.ClientLogin.Equals(model.ClientLogin) && x.ClientPassword.Equals(model.ClientPassword))?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.HeadwaiterLogin))
|
||||
return context.Headwaiters
|
||||
if (!string.IsNullOrEmpty(model.ClientLogin))
|
||||
return context.Clients
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.FirstOrDefault(x => x.HeadwaiterLogin.Equals(model.HeadwaiterLogin))?
|
||||
.FirstOrDefault(x => x.ClientLogin.Equals(model.ClientLogin))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
@ -64,18 +64,18 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.HeadwaiterFIO))
|
||||
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Headwaiters
|
||||
return context.Clients
|
||||
.Include(x => x.ConferenceBookings)
|
||||
.Include(x => x.Dinners)
|
||||
.Include(x => x.Rooms)
|
||||
.Where(x => x.HeadwaiterLogin.Contains(model.HeadwaiterLogin) && x.HeadwaiterPassword == model.HeadwaiterPassword)
|
||||
.Where(x => x.ClientLogin.Contains(model.ClientLogin) && x.ClientPassword == model.ClientPassword)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
return context.Headwaiters
|
||||
return context.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -100,7 +100,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
|
||||
using var context = new BankDataBase();
|
||||
|
||||
context.Headwaiters.Add(newHeadwaiter);
|
||||
context.Clients.Add(newHeadwaiter);
|
||||
context.SaveChanges();
|
||||
|
||||
return newHeadwaiter.GetViewModel;
|
||||
@ -110,7 +110,7 @@ namespace BankDataBaseImplement.Implemets
|
||||
{
|
||||
using var context = new BankDataBase();
|
||||
|
||||
var headwaiter = context.Headwaiters
|
||||
var headwaiter = context.Clients
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (headwaiter == null)
|
||||
|
@ -9,22 +9,22 @@ namespace BankDataBaseImplement.Models
|
||||
public class Clerc : IClercModel
|
||||
{
|
||||
[Required]
|
||||
public string OrganiserFIO { get; set; } = string.Empty;
|
||||
public string ClercFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string OrganiserPassword { get; set; } = string.Empty;
|
||||
public string ClercPassword { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string OrganiserLogin { get; set; } = string.Empty;
|
||||
public string ClercLogin { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string OrganiserEmail { get; set; } = string.Empty;
|
||||
public string ClercEmail { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string OrganiserNumber { get; set; } = string.Empty;
|
||||
public string ClercNumber { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
[ForeignKey("OrganiserId")]
|
||||
public virtual List<Conference> Conferences { get; set; } = new();
|
||||
[ForeignKey("OrganiserId")]
|
||||
public virtual List<Additions> MealPlans { get; set; } = new();
|
||||
public virtual List<Additions> Additions { get; set; } = new();
|
||||
[ForeignKey("OrganiserId")]
|
||||
public virtual List<Member> Members { get; set; } = new();
|
||||
|
||||
@ -37,11 +37,11 @@ namespace BankDataBaseImplement.Models
|
||||
return new Clerc()
|
||||
{
|
||||
Id = model.Id,
|
||||
OrganiserFIO = model.OrganiserFIO,
|
||||
OrganiserEmail = model.OrganiserEmail,
|
||||
OrganiserPassword = model.OrganiserPassword,
|
||||
OrganiserLogin = model.OrganiserLogin,
|
||||
OrganiserNumber = model.OrganiserNumber
|
||||
ClercFIO = model.ClercFIO,
|
||||
ClercEmail = model.ClercEmail,
|
||||
ClercPassword = model.ClercPassword,
|
||||
ClercLogin = model.ClercLogin,
|
||||
ClercNumber = model.ClercNumber
|
||||
};
|
||||
}
|
||||
public static Clerc Create(ClercViewModel model)
|
||||
@ -49,11 +49,11 @@ namespace BankDataBaseImplement.Models
|
||||
return new Clerc
|
||||
{
|
||||
Id = model.Id,
|
||||
OrganiserFIO = model.OrganiserFIO,
|
||||
OrganiserEmail = model.OrganiserEmail,
|
||||
OrganiserPassword = model.OrganiserPassword,
|
||||
OrganiserLogin= model.OrganiserLogin,
|
||||
OrganiserNumber= model.OrganiserNumber
|
||||
ClercFIO = model.ClercFIO,
|
||||
ClercEmail = model.ClercEmail,
|
||||
ClercPassword = model.ClercPassword,
|
||||
ClercLogin = model.ClercLogin,
|
||||
ClercNumber = model.ClercNumber
|
||||
};
|
||||
}
|
||||
public void Update(ClercBindingModel model)
|
||||
@ -62,20 +62,20 @@ namespace BankDataBaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
OrganiserFIO = model.OrganiserFIO;
|
||||
OrganiserEmail = model.OrganiserEmail;
|
||||
OrganiserPassword = model.OrganiserPassword;
|
||||
OrganiserLogin = model.OrganiserLogin;
|
||||
OrganiserNumber = model.OrganiserNumber;
|
||||
ClercFIO = model.ClercFIO;
|
||||
ClercEmail = model.ClercEmail;
|
||||
ClercPassword = model.ClercPassword;
|
||||
ClercLogin = model.ClercLogin;
|
||||
ClercNumber = model.ClercNumber;
|
||||
}
|
||||
public ClercViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
OrganiserFIO = OrganiserFIO,
|
||||
OrganiserEmail = OrganiserEmail,
|
||||
OrganiserPassword = OrganiserPassword,
|
||||
OrganiserNumber = OrganiserNumber,
|
||||
OrganiserLogin = OrganiserLogin
|
||||
ClercFIO = ClercFIO,
|
||||
ClercEmail = ClercEmail,
|
||||
ClercPassword = ClercPassword,
|
||||
ClercNumber = ClercNumber,
|
||||
ClercLogin = ClercLogin
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,19 @@ namespace BankDataBaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string HeadwaiterFIO { get; set; } = string.Empty;
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string HeadwaiterEmail { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string HeadwaiterPassword { get; set; } = string.Empty;
|
||||
public string ClientPassword { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string HeadwaiterLogin { get; set; } = string.Empty;
|
||||
public string ClientLogin { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string HeadwaiterNumber { get; set; } = string.Empty;
|
||||
public string ClientNumber { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[ForeignKey("HeadwaiterId")]
|
||||
@ -48,11 +48,11 @@ namespace BankDataBaseImplement.Models
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
HeadwaiterFIO = model.HeadwaiterFIO,
|
||||
HeadwaiterEmail = model.HeadwaiterEmail,
|
||||
HeadwaiterPassword = model.HeadwaiterPassword,
|
||||
HeadwaiterLogin = model.HeadwaiterLogin,
|
||||
HeadwaiterNumber = model.HeadwaiterNumber
|
||||
ClientFIO = model.ClientFIO,
|
||||
ClientEmail = model.ClientEmail,
|
||||
ClientPassword = model.ClientPassword,
|
||||
ClientLogin = model.ClientLogin,
|
||||
ClientNumber = model.ClientNumber
|
||||
};
|
||||
}
|
||||
public static Client Create(ClientViewModel model)
|
||||
@ -60,11 +60,11 @@ namespace BankDataBaseImplement.Models
|
||||
return new Client
|
||||
{
|
||||
Id = model.Id,
|
||||
HeadwaiterFIO = model.HeadwaiterFIO,
|
||||
HeadwaiterEmail = model.HeadwaiterEmail,
|
||||
HeadwaiterPassword = model.HeadwaiterPassword,
|
||||
HeadwaiterLogin = model.HeadwaiterLogin,
|
||||
HeadwaiterNumber = model.HeadwaiterNumber
|
||||
ClientFIO = model.ClientFIO,
|
||||
ClientEmail = model.ClientEmail,
|
||||
ClientPassword = model.ClientPassword,
|
||||
ClientLogin = model.ClientLogin,
|
||||
ClientNumber = model.ClientNumber
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
@ -73,20 +73,20 @@ namespace BankDataBaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
HeadwaiterFIO = model.HeadwaiterFIO;
|
||||
HeadwaiterEmail = model.HeadwaiterEmail;
|
||||
HeadwaiterPassword = model.HeadwaiterPassword;
|
||||
HeadwaiterLogin = model.HeadwaiterLogin;
|
||||
HeadwaiterNumber = model.HeadwaiterNumber;
|
||||
ClientFIO = model.ClientFIO;
|
||||
ClientEmail = model.ClientEmail;
|
||||
ClientPassword = model.ClientPassword;
|
||||
ClientLogin = model.ClientLogin;
|
||||
ClientNumber = model.ClientNumber;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
HeadwaiterFIO = HeadwaiterFIO,
|
||||
HeadwaiterEmail = HeadwaiterEmail,
|
||||
HeadwaiterPassword = HeadwaiterPassword,
|
||||
HeadwaiterLogin = HeadwaiterLogin,
|
||||
HeadwaiterNumber = HeadwaiterNumber
|
||||
ClientFIO = ClientFIO,
|
||||
ClientEmail = ClientEmail,
|
||||
ClientPassword = ClientPassword,
|
||||
ClientLogin = ClientLogin,
|
||||
ClientNumber = ClientNumber
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
{
|
||||
public interface IAdditionsModel : IId
|
||||
{
|
||||
string MealPlanName { get; }
|
||||
double MealPlanPrice { get; }
|
||||
int OrganiserId { get; }
|
||||
public Dictionary<int, IMemberModel> MealPlanMembers { get; }
|
||||
string AdditionsName { get; }
|
||||
double AdditionsPrice { get; }
|
||||
int ClercId { get; }
|
||||
public Dictionary<int, IMemberModel> AdditionsMembers { get; }
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
{
|
||||
public interface IClercModel : IId
|
||||
{
|
||||
string OrganiserFIO { get; }
|
||||
string OrganiserPassword { get; }
|
||||
string OrganiserLogin { get; }
|
||||
string OrganiserEmail { get; }
|
||||
string OrganiserNumber { get; }
|
||||
string ClercFIO { get; }
|
||||
string ClercPassword { get; }
|
||||
string ClercLogin { get; }
|
||||
string ClercEmail { get; }
|
||||
string ClercNumber { get; }
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ namespace BankDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string HeadwaiterFIO { get; }
|
||||
string HeadwaiterPassword { get; }
|
||||
string HeadwaiterLogin { get; }
|
||||
string HeadwaiterEmail { get; }
|
||||
string HeadwaiterNumber { get; }
|
||||
string ClientFIO { get; }
|
||||
string ClientPassword { get; }
|
||||
string ClientLogin { get; }
|
||||
string ClientEmail { get; }
|
||||
string ClientNumber { get; }
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
{
|
||||
public interface ICreditModel : IId
|
||||
{
|
||||
string DinnerName { get; }
|
||||
double DinnerPrice { get; }
|
||||
int HeadwaiterId { get; }
|
||||
string CreditName { get; }
|
||||
double CreditPrice { get; }
|
||||
int ClientId { get; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user