From 5c6db64994aad11d681f89f0e7585a221d030360 Mon Sep 17 00:00:00 2001 From: Arklightning Date: Sun, 9 Apr 2023 12:14:52 +0400 Subject: [PATCH] Comit3 --- .../BuisinessLogics/AdditionsLogic.cs | 22 +++---- .../BuisinessLogics/ClercLogic.cs | 2 +- .../BuisinessLogics/ClientLogic.cs | 58 +++++++++---------- .../BindingModels/ClercBindingModel.cs | 10 ++-- .../BindingModels/ClientBindingModel.cs | 10 ++-- .../BindingModels/CreditBindingModel.cs | 6 +- .../SearchModels/AdditionsSearchModel.cs | 2 +- .../SearchModels/ClercSearchModel.cs | 6 +- .../SearchModels/ClientSearchModel.cs | 6 +- .../SearchModels/CreditSearchModel.cs | 2 +- ...HeadwaiterStorage.cs => IClientStorage.cs} | 2 +- .../ViewModels/ClercViewModel.cs | 10 ++-- .../ViewModels/ClientViewModel.cs | 10 ++-- .../ViewModels/CreditViewModel.cs | 6 +- Bank/BankDataBaseImplement/BankDataBase.cs | 10 ++-- .../Implemets/AdditionsStorage.cs | 18 +++--- .../Implemets/ClercStorage.cs | 38 ++++++------ .../Implemets/ClientStorage.cs | 32 +++++----- Bank/BankDataBaseImplement/Models/Clerc.cs | 52 ++++++++--------- Bank/BankDataBaseImplement/Models/Client.cs | 50 ++++++++-------- .../DataModels/IAdditionsModel.cs | 8 +-- Bank/BankDataModels/DataModels/IClercModel.cs | 10 ++-- .../BankDataModels/DataModels/IClientModel.cs | 10 ++-- .../BankDataModels/DataModels/ICreditModel.cs | 6 +- 24 files changed, 193 insertions(+), 193 deletions(-) rename Bank/BankContracts/StoragesContracts/{IHeadwaiterStorage.cs => IClientStorage.cs} (92%) diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/AdditionsLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/AdditionsLogic.cs index 9a6bd73..2cdbc4d 100644 --- a/Bank/BankBuisinessLogics/BuisinessLogics/AdditionsLogic.cs +++ b/Bank/BankBuisinessLogics/BuisinessLogics/AdditionsLogic.cs @@ -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 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? 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) diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs index 3913cae..4236f9a 100644 --- a/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ClercLogic.cs @@ -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 logger, IClercStorage clercStorage) { diff --git a/Bank/BankBuisinessLogics/BuisinessLogics/ClientLogic.cs b/Bank/BankBuisinessLogics/BuisinessLogics/ClientLogic.cs index 3588ab4..b2e46c4 100644 --- a/Bank/BankBuisinessLogics/BuisinessLogics/ClientLogic.cs +++ b/Bank/BankBuisinessLogics/BuisinessLogics/ClientLogic.cs @@ -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 logger, IHeadwaiterStorage headwaiterStorage) + public ClientLogic(ILogger 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? 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) diff --git a/Bank/BankContracts/BindingModels/ClercBindingModel.cs b/Bank/BankContracts/BindingModels/ClercBindingModel.cs index a3844c1..3c806bf 100644 --- a/Bank/BankContracts/BindingModels/ClercBindingModel.cs +++ b/Bank/BankContracts/BindingModels/ClercBindingModel.cs @@ -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; } } diff --git a/Bank/BankContracts/BindingModels/ClientBindingModel.cs b/Bank/BankContracts/BindingModels/ClientBindingModel.cs index b79ac65..e03276c 100644 --- a/Bank/BankContracts/BindingModels/ClientBindingModel.cs +++ b/Bank/BankContracts/BindingModels/ClientBindingModel.cs @@ -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; } } diff --git a/Bank/BankContracts/BindingModels/CreditBindingModel.cs b/Bank/BankContracts/BindingModels/CreditBindingModel.cs index 5ca52aa..f999c94 100644 --- a/Bank/BankContracts/BindingModels/CreditBindingModel.cs +++ b/Bank/BankContracts/BindingModels/CreditBindingModel.cs @@ -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; } } diff --git a/Bank/BankContracts/SearchModels/AdditionsSearchModel.cs b/Bank/BankContracts/SearchModels/AdditionsSearchModel.cs index c85361e..6778856 100644 --- a/Bank/BankContracts/SearchModels/AdditionsSearchModel.cs +++ b/Bank/BankContracts/SearchModels/AdditionsSearchModel.cs @@ -3,6 +3,6 @@ public class AdditionsSearchModel { public int? Id { get; set; } - public string? MealPlanName { get; set; } + public string? AdditionsName { get; set; } } } diff --git a/Bank/BankContracts/SearchModels/ClercSearchModel.cs b/Bank/BankContracts/SearchModels/ClercSearchModel.cs index aaf951d..8ed2b9b 100644 --- a/Bank/BankContracts/SearchModels/ClercSearchModel.cs +++ b/Bank/BankContracts/SearchModels/ClercSearchModel.cs @@ -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; } } } diff --git a/Bank/BankContracts/SearchModels/ClientSearchModel.cs b/Bank/BankContracts/SearchModels/ClientSearchModel.cs index 58393e5..802cde3 100644 --- a/Bank/BankContracts/SearchModels/ClientSearchModel.cs +++ b/Bank/BankContracts/SearchModels/ClientSearchModel.cs @@ -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; } } } diff --git a/Bank/BankContracts/SearchModels/CreditSearchModel.cs b/Bank/BankContracts/SearchModels/CreditSearchModel.cs index 020b7bf..fa4c444 100644 --- a/Bank/BankContracts/SearchModels/CreditSearchModel.cs +++ b/Bank/BankContracts/SearchModels/CreditSearchModel.cs @@ -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; } } } diff --git a/Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs b/Bank/BankContracts/StoragesContracts/IClientStorage.cs similarity index 92% rename from Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs rename to Bank/BankContracts/StoragesContracts/IClientStorage.cs index 7dd02e9..f85c07e 100644 --- a/Bank/BankContracts/StoragesContracts/IHeadwaiterStorage.cs +++ b/Bank/BankContracts/StoragesContracts/IClientStorage.cs @@ -4,7 +4,7 @@ using BankContracts.ViewModels; namespace BankContracts.StoragesContracts { - public interface IHeadwaiterStorage + public interface IClientStorage { List GetFullList(); diff --git a/Bank/BankContracts/ViewModels/ClercViewModel.cs b/Bank/BankContracts/ViewModels/ClercViewModel.cs index 3401ab5..019f69d 100644 --- a/Bank/BankContracts/ViewModels/ClercViewModel.cs +++ b/Bank/BankContracts/ViewModels/ClercViewModel.cs @@ -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; } } diff --git a/Bank/BankContracts/ViewModels/ClientViewModel.cs b/Bank/BankContracts/ViewModels/ClientViewModel.cs index f6e40fe..52de8a7 100644 --- a/Bank/BankContracts/ViewModels/ClientViewModel.cs +++ b/Bank/BankContracts/ViewModels/ClientViewModel.cs @@ -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; } } diff --git a/Bank/BankContracts/ViewModels/CreditViewModel.cs b/Bank/BankContracts/ViewModels/CreditViewModel.cs index 7d12964..e1ddce0 100644 --- a/Bank/BankContracts/ViewModels/CreditViewModel.cs +++ b/Bank/BankContracts/ViewModels/CreditViewModel.cs @@ -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; } } } diff --git a/Bank/BankDataBaseImplement/BankDataBase.cs b/Bank/BankDataBaseImplement/BankDataBase.cs index c40bf85..2ece93d 100644 --- a/Bank/BankDataBaseImplement/BankDataBase.cs +++ b/Bank/BankDataBaseImplement/BankDataBase.cs @@ -16,14 +16,14 @@ namespace BankDataBaseImplement } public virtual DbSet Conferences { set; get; } public virtual DbSet Rooms { set; get; } - public virtual DbSet MealPlans { set; get; } + public virtual DbSet Additions { set; get; } public virtual DbSet ConferenceBookings { set; get; } public virtual DbSet Members { set; get; } - public virtual DbSet Dinners { set; get; } - public virtual DbSet Organisers { set; get; } - public virtual DbSet Headwaiters { set; get; } + public virtual DbSet Credits { set; get; } + public virtual DbSet Clercs { set; get; } + public virtual DbSet Clients { set; get; } public virtual DbSet ConferenceMembers { set; get; } - public virtual DbSet RoomDinners { set; get; } + public virtual DbSet RoomCredits { set; get; } public virtual DbSet MealPlanMembers { set; get; } public virtual DbSet ConferenceBookingDinners { set; get; } diff --git a/Bank/BankDataBaseImplement/Implemets/AdditionsStorage.cs b/Bank/BankDataBaseImplement/Implemets/AdditionsStorage.cs index 761b2d9..dfbae25 100644 --- a/Bank/BankDataBaseImplement/Implemets/AdditionsStorage.cs +++ b/Bank/BankDataBaseImplement/Implemets/AdditionsStorage.cs @@ -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 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 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; diff --git a/Bank/BankDataBaseImplement/Implemets/ClercStorage.cs b/Bank/BankDataBaseImplement/Implemets/ClercStorage.cs index f5b08ac..b7d569c 100644 --- a/Bank/BankDataBaseImplement/Implemets/ClercStorage.cs +++ b/Bank/BankDataBaseImplement/Implemets/ClercStorage.cs @@ -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 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) diff --git a/Bank/BankDataBaseImplement/Implemets/ClientStorage.cs b/Bank/BankDataBaseImplement/Implemets/ClientStorage.cs index 08c73af..39c843b 100644 --- a/Bank/BankDataBaseImplement/Implemets/ClientStorage.cs +++ b/Bank/BankDataBaseImplement/Implemets/ClientStorage.cs @@ -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 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) diff --git a/Bank/BankDataBaseImplement/Models/Clerc.cs b/Bank/BankDataBaseImplement/Models/Clerc.cs index 06c6b01..ec417e7 100644 --- a/Bank/BankDataBaseImplement/Models/Clerc.cs +++ b/Bank/BankDataBaseImplement/Models/Clerc.cs @@ -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 Conferences { get; set; } = new(); [ForeignKey("OrganiserId")] - public virtual List MealPlans { get; set; } = new(); + public virtual List Additions { get; set; } = new(); [ForeignKey("OrganiserId")] public virtual List 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 }; } } diff --git a/Bank/BankDataBaseImplement/Models/Client.cs b/Bank/BankDataBaseImplement/Models/Client.cs index 8ed8007..51e9f61 100644 --- a/Bank/BankDataBaseImplement/Models/Client.cs +++ b/Bank/BankDataBaseImplement/Models/Client.cs @@ -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 }; } diff --git a/Bank/BankDataModels/DataModels/IAdditionsModel.cs b/Bank/BankDataModels/DataModels/IAdditionsModel.cs index 0d964ea..4d3bd83 100644 --- a/Bank/BankDataModels/DataModels/IAdditionsModel.cs +++ b/Bank/BankDataModels/DataModels/IAdditionsModel.cs @@ -2,9 +2,9 @@ { public interface IAdditionsModel : IId { - string MealPlanName { get; } - double MealPlanPrice { get; } - int OrganiserId { get; } - public Dictionary MealPlanMembers { get; } + string AdditionsName { get; } + double AdditionsPrice { get; } + int ClercId { get; } + public Dictionary AdditionsMembers { get; } } } diff --git a/Bank/BankDataModels/DataModels/IClercModel.cs b/Bank/BankDataModels/DataModels/IClercModel.cs index f00dd23..0b86313 100644 --- a/Bank/BankDataModels/DataModels/IClercModel.cs +++ b/Bank/BankDataModels/DataModels/IClercModel.cs @@ -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; } } } diff --git a/Bank/BankDataModels/DataModels/IClientModel.cs b/Bank/BankDataModels/DataModels/IClientModel.cs index 048d277..4f361d8 100644 --- a/Bank/BankDataModels/DataModels/IClientModel.cs +++ b/Bank/BankDataModels/DataModels/IClientModel.cs @@ -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; } } } diff --git a/Bank/BankDataModels/DataModels/ICreditModel.cs b/Bank/BankDataModels/DataModels/ICreditModel.cs index 01b027b..df98d13 100644 --- a/Bank/BankDataModels/DataModels/ICreditModel.cs +++ b/Bank/BankDataModels/DataModels/ICreditModel.cs @@ -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; } } }