From 77e3b7c3d40d84fc5ae9aa7b975b6011ce836abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 30 Apr 2024 18:09:55 +0400 Subject: [PATCH 1/2] =?UTF-8?q?Room=20(=D0=B1=D0=B5=D0=B7=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=B5=D0=B4=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/RoomLogic.cs | 53 ++------- .../BusinessLogicsContracts/IRoomLogic.cs | 1 - .../ViewModels/RoomViewModel.cs | 8 -- Hotel/HotelDataBaseImplement/HotelDataBase.cs | 2 +- Hotel/HotelDataBaseImplement/Models/Room.cs | 4 +- .../Controllers/HomeController.cs | 93 ++++++--------- .../Views/Home/CreateRoom.cshtml | 76 ++++--------- .../Views/Home/UpdateRoom.cshtml | 45 ++++---- .../Controllers/RoomController.cs | 107 ++++++++---------- 9 files changed, 139 insertions(+), 250 deletions(-) diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/RoomLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogics/RoomLogic.cs index 02c06c0..f94c610 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogics/RoomLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogics/RoomLogic.cs @@ -58,48 +58,11 @@ namespace HotelBusinessLogic.BusinessLogics return element; } - public bool AddLunchToRoom(RoomSearchModel model, ILunchModel lunch) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - _logger.LogInformation("AddLunchToRoom. RoomName:{RoomName}.Id:{ Id}", model.RoomName, model.Id); - var element = _roomStorage.GetElement(model); - - if (element == null) - { - _logger.LogWarning("AddLunchToRoom element not found"); - return false; - } - - _logger.LogInformation("AddLunchToRoom find. Id:{Id}", element.Id); - - element.RoomLunches[lunch.Id] = lunch; - - _roomStorage.Update(new() - { - Id = element.Id, - RoomName = element.RoomName, - RoomPrice = element.RoomPrice, - RoomFrame = element.RoomFrame, - MealPlanId = element.MealPlanId, - HeadwaiterId = element.HeadwaiterId, - RoomLunches = element.RoomLunches, - }); - - return true; - } - public bool Create(RoomBindingModel model) { CheckModel(model); - model.RoomLunches = new(); - var result = _roomStorage.Insert(model); - - if (result == null) + if (_roomStorage.Insert(model) == null) { _logger.LogWarning("Insert operation failed"); return false; @@ -127,9 +90,7 @@ namespace HotelBusinessLogic.BusinessLogics _logger.LogInformation("Delete. Id:{Id}", model.Id); - var result = _roomStorage.Delete(model); - - if (result == null) + if (_roomStorage.Delete(model) == null) { _logger.LogWarning("Delete operation failed"); return false; @@ -166,6 +127,16 @@ namespace HotelBusinessLogic.BusinessLogics throw new ArgumentNullException("Стоимость комнаты не может быть меньше 0", nameof(model.RoomPrice)); } + var element = _roomStorage.GetElement(new RoomSearchModel + { + RoomName = model.RoomName + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Услуга с таким названием уже есть"); + } + _logger.LogInformation("Room. RoomName:{RoomName}.RoomFrame:{ RoomFrame}.RoomPrice:{ RoomPrice}. Id: { Id}", model.RoomName, model.RoomFrame, model.RoomPrice, model.Id); } } diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs index 0abdf76..d975476 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IRoomLogic.cs @@ -9,7 +9,6 @@ namespace HotelContracts.BusinessLogicsContracts { List? ReadList(RoomSearchModel? model); RoomViewModel? ReadElement(RoomSearchModel model); - bool AddLunchToRoom(RoomSearchModel model, ILunchModel lunch); bool Create(RoomBindingModel model); bool Update(RoomBindingModel model); bool Delete(RoomBindingModel model); diff --git a/Hotel/HotelContracts/ViewModels/RoomViewModel.cs b/Hotel/HotelContracts/ViewModels/RoomViewModel.cs index e5b19d8..7495984 100644 --- a/Hotel/HotelContracts/ViewModels/RoomViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/RoomViewModel.cs @@ -22,13 +22,5 @@ namespace HotelContracts.ViewModels public int HeadwaiterId { get; set; } public Dictionary RoomLunches { get; set; } - - public RoomViewModel() { } - - [JsonConstructor] - public RoomViewModel(Dictionary RoomLunches) - { - this.RoomLunches = RoomLunches.ToDictionary(x => x.Key, x => x.Value as ILunchModel); - } } } diff --git a/Hotel/HotelDataBaseImplement/HotelDataBase.cs b/Hotel/HotelDataBaseImplement/HotelDataBase.cs index bd1a1f2..d5436cd 100644 --- a/Hotel/HotelDataBaseImplement/HotelDataBase.cs +++ b/Hotel/HotelDataBaseImplement/HotelDataBase.cs @@ -10,7 +10,7 @@ namespace HotelDataBaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-7DB3VEN\SQLEXPRESS;Initial Catalog=HotelDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-M2G96S06\SQLEXPRESS;Initial Catalog=HotelDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/Hotel/HotelDataBaseImplement/Models/Room.cs b/Hotel/HotelDataBaseImplement/Models/Room.cs index be1422d..d79a13c 100644 --- a/Hotel/HotelDataBaseImplement/Models/Room.cs +++ b/Hotel/HotelDataBaseImplement/Models/Room.cs @@ -37,9 +37,7 @@ namespace HotelDataBaseImplement.Models { if (_roomLunches == null) { - using var context = new HotelDataBase(); - _roomLunches = Lunches.ToDictionary(x => x.LunchId, x => (context.Lunches - .FirstOrDefault(y => y.Id == x.LunchId)! as ILunchModel)); + _roomLunches = Lunches.ToDictionary(x => x.LunchId, x => (x.Lunch as ILunchModel)); } return _roomLunches; } diff --git a/Hotel/HotelHeadwaiterApp/Controllers/HomeController.cs b/Hotel/HotelHeadwaiterApp/Controllers/HomeController.cs index c2f8253..bbd3282 100644 --- a/Hotel/HotelHeadwaiterApp/Controllers/HomeController.cs +++ b/Hotel/HotelHeadwaiterApp/Controllers/HomeController.cs @@ -4,6 +4,7 @@ using HotelContracts.BindingModels; using HotelContracts.SearchModels; using HotelContracts.ViewModels; using HotelDataBaseImplement.Models; +using HotelDataModels.Models; using HotelHeadwaiterApp.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; @@ -235,20 +236,21 @@ namespace HotelHeadwaiterApp.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}")); + return View(APIClient.GetRequest>($"api/room/getrooms?headwaiterId={APIClient.Headwaiter.Id}")); } - public IActionResult CreateRoom() + public IActionResult CreateRoom() { if (APIClient.Headwaiter == null) { return Redirect("~/Home/Enter"); } + ViewBag.Lunches = APIClient.GetRequest>($"api/lunch/getlunches"); return View(); } [HttpPost] - public void CreateRoom(string roomName, double roomPrice, string roomFrame) + public void CreateRoom(string roomName, string roomFrame, double roomPrice, List lunches) { if (APIClient.Headwaiter == null) { @@ -266,12 +268,18 @@ namespace HotelHeadwaiterApp.Controllers { throw new Exception("Цена не может быть отрицательной"); } + Dictionary a = new Dictionary(); + foreach (int lunch in lunches) + { + a.Add(lunch, new LunchSearchModel { Id = lunch } as ILunchModel); + } APIClient.PostRequest("api/room/createroom", new RoomBindingModel { RoomName = roomName, RoomPrice = roomPrice, RoomFrame = roomFrame, HeadwaiterId = APIClient.Headwaiter.Id, + RoomLunches = a }); Response.Redirect("ListRooms"); } @@ -282,12 +290,13 @@ namespace HotelHeadwaiterApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Rooms = APIClient.GetRequest>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}"); + ViewBag.Rooms = APIClient.GetRequest>($"api/room/getrooms?headwaiterId={APIClient.Headwaiter.Id}"); + ViewBag.Lunches = APIClient.GetRequest>($"api/lunch/getlunches"); return View(); } [HttpPost] - public void UpdateRoom(int room, string roomName, double roomPrice, string roomFrame) + public void UpdateRoom(int room, string roomName, double roomPrice, string roomFrame, List lunches) { if (APIClient.Headwaiter == null) { @@ -305,70 +314,40 @@ namespace HotelHeadwaiterApp.Controllers { throw new Exception("Цена не может быть отрицательной"); } + Dictionary a = new Dictionary(); + foreach (int lunch in lunches) + { + a.Add(lunch, new LunchSearchModel { Id = lunch } as ILunchModel); + } APIClient.PostRequest("api/room/updateroom", new RoomBindingModel { Id = room, RoomName = roomName, RoomPrice = roomPrice, RoomFrame = roomFrame, - HeadwaiterId = APIClient.Headwaiter.Id + HeadwaiterId = APIClient.Headwaiter.Id, + RoomLunches = a }); Response.Redirect("ListRooms"); } - [HttpGet] - public Tuple? GetRoom(int roomId) - { - if (APIClient.Headwaiter == null) - { - throw new Exception("Необходима авторизация"); - } - var result = APIClient.GetRequest>>>($"api/room/getroombyid?roomId={roomId}"); - if (result == null) - { - return default; - } - string table = ""; - for (int i = 0; i < result.Item2.Count; i++) - { - var lunchName = result.Item2[i].Item1; - var lunchPrice = result.Item2[i].Item2; - table += ""; - table += $"{lunchName}"; - table += $"{lunchPrice}"; - table += ""; - } - return Tuple.Create(result.Item1, table); - } + [HttpGet] + public Tuple>? GetRoom(int roomId) + { + if (APIClient.Headwaiter == null) + { + throw new Exception("Необходима авторизация"); + } + var result = APIClient.GetRequest>>($"api/room/getroom?roomId={roomId}"); + if (result == null) + { + return default; + } - public IActionResult AddLunchToRoom() - { - if (APIClient.Headwaiter == null) - { - return Redirect("~/Home/Enter"); - } - return View(Tuple.Create(APIClient.GetRequest>($"api/room/getroomlist?headwaiterId={APIClient.Headwaiter.Id}"), - APIClient.GetRequest>($"api/lunch/getlunchlist?headwaiterId={APIClient.Headwaiter.Id}"))); - } + return result; + } - [HttpPost] - public void AddLunchToRoom(int room, int[] lunch) - { - if (APIClient.Headwaiter == null) - { - throw new Exception("Необходима авторизация"); - } - for (int i = 0; i < lunch.Length; i++) - { - APIClient.PostRequest("api/room/AddLunchToRoom", Tuple.Create( - new RoomSearchModel() { Id = room }, - new LunchViewModel() { Id = lunch[i] } - )); - } - Response.Redirect("ListRooms"); - } - - public IActionResult DeleteRoom() + public IActionResult DeleteRoom() { if (APIClient.Headwaiter == null) { diff --git a/Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml b/Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml index 4e8f4a2..696ecae 100644 --- a/Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml +++ b/Hotel/HotelHeadwaiterApp/Views/Home/CreateRoom.cshtml @@ -1,7 +1,4 @@ -@using HotelContracts.ViewModels; -@using HotelDataModels.Models; - -@{ +@{ ViewData["Title"] = "CreateRoom"; } @@ -16,15 +13,6 @@ placeholder="Введите название комнаты" name="roomName" class="form-control" /> -
-
- -
- -
@@ -32,51 +20,27 @@ placeholder="Введите корпус комнаты" name="roomFrame" class="form-control" /> -
-
- - - - - - - - - - -
- Обед - - Цена -
+
+ +
+ +
+ +
+
+
+ +
- -@section Scripts -{ - -} \ No newline at end of file diff --git a/Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml b/Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml index 1aa7186..93ebf2d 100644 --- a/Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml +++ b/Hotel/HotelHeadwaiterApp/Views/Home/UpdateRoom.cshtml @@ -21,6 +21,14 @@ name="roomName" class="form-control" />
+
+ + +
- - +
-
- - - - - - - - - - -
- Обед - - Цена -
+
+
+ +

@@ -74,7 +70,10 @@ $('#roomName').val(result.item1.roomName); $('#roomPrice').val(result.item1.roomPrice); $('#roomFrame').val(result.item1.roomFrame); - $('#table-elements').html(result.item2); + $.map(result.item2, function (n) { + console.log("#" + n); + $("#" + n).attr("selected", "selected") + }); } }); }; diff --git a/Hotel/HotelRestApi/Controllers/RoomController.cs b/Hotel/HotelRestApi/Controllers/RoomController.cs index f34dd86..4ed78ed 100644 --- a/Hotel/HotelRestApi/Controllers/RoomController.cs +++ b/Hotel/HotelRestApi/Controllers/RoomController.cs @@ -2,6 +2,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.ViewModels; +using HotelDataBaseImplement.Models; using Microsoft.AspNetCore.Mvc; namespace HotelRestApi.Controllers @@ -19,55 +20,55 @@ namespace HotelRestApi.Controllers _room = room; } - [HttpGet] - public List? GetRoomList(int headwaiterId) - { - try - { - return _room.ReadList(new RoomSearchModel + [HttpGet] + public List GetRooms(int? headwaiterId = null) + { + try + { + List res; + if (!headwaiterId.HasValue) { - HeadwaiterId = headwaiterId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка номеров"); - throw; - } - } - - [HttpGet] - public List? GetRooms() - { - try - { - return _room.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка номеров"); - throw; - } - } - - [HttpGet] - public RoomViewModel? GetRoomById(int roomId) - { - try - { - return _room.ReadElement(new RoomSearchModel + res = _room.ReadList(null); + } + else { - Id = roomId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения номера по id={Id}", roomId); - throw; - } - } + res = _room.ReadList(new RoomSearchModel { HeadwaiterId = headwaiterId }); + } + foreach (var service in res) + { + service.RoomLunches = null; + } + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка номеров"); + throw; + } + } - [HttpPost] + [HttpGet] + public Tuple>? GetRoom(int roomId) + { + try + { + var elem = _room.ReadElement(new RoomSearchModel { Id = roomId }); + if (elem == null) + { + return null; + } + var res = Tuple.Create(elem, elem.RoomLunches.Select(x => x.Value.LunchName).ToList()); + res.Item1.RoomLunches = null!; + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения номера по id={Id}", roomId); + throw; + } + } + + [HttpPost] public void CreateRoom(RoomBindingModel model) { try @@ -109,19 +110,5 @@ namespace HotelRestApi.Controllers throw; } } - - [HttpPost] - public void AddLunchToRoom(Tuple model) - { - try - { - _room.AddLunchToRoom(model.Item1, model.Item2); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка добавления обеда к номеру."); - throw; - } - } } } From cf109109bc1c88d54a3edd10db60e6b43fa11bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 30 Apr 2024 22:30:12 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ConferenceBookingLogic.cs | 33 ----- .../BusinessLogics/ConferenceLogic.cs | 32 ----- .../BusinessLogics/MealPlanLogic.cs | 32 ----- .../IConferenceBookingLogic.cs | 1 - .../IConferenceLogic.cs | 1 - .../BusinessLogicsContracts/IMealPlanLogic.cs | 1 - .../ViewModels/ConferenceBookingViewModel.cs | 8 -- .../ViewModels/ConferenceViewModel.cs | 8 -- .../ViewModels/MealPlanViewModel.cs | 9 -- .../Models/Conference.cs | 6 +- .../Models/ConferenceBooking.cs | 7 +- .../HotelDataBaseImplement/Models/MealPlan.cs | 6 +- .../ConferenceBookingController.cs | 115 ++++++--------- .../Controllers/ConferenceController.cs | 113 +++++++-------- .../Controllers/LunchController.cs | 80 +++++------ .../Controllers/MealPlanController.cs | 69 +++++---- .../Controllers/MemberController.cs | 69 ++++----- .../Controllers/RoomController.cs | 134 +++++++++--------- 18 files changed, 265 insertions(+), 459 deletions(-) diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceBookingLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceBookingLogic.cs index c8d2e8e..de9c52c 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceBookingLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceBookingLogic.cs @@ -58,39 +58,6 @@ namespace HotelBusinessLogic.BusinessLogics return element; } - public bool AddLunchToConferenceBooking(ConferenceBookingSearchModel model, ILunchModel lunch) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - _logger.LogInformation("AddLunchToConferenceBooking. NameHall:{NameHall}.Id:{ Id}", model.NameHall, model.Id); - var element = _conferenceBookingStorage.GetElement(model); - - if (element == null) - { - _logger.LogWarning("AddLunchToConferenceBooking element not found"); - return false; - } - - _logger.LogInformation("AddLunchToConferenceBooking find. Id:{Id}", element.Id); - - element.ConferenceBookingLunches[lunch.Id] = lunch; - - _conferenceBookingStorage.Update(new() - { - Id = element.Id, - NameHall = element.NameHall, - BookingDate = element.BookingDate, - ConferenceId = element.ConferenceId, - HeadwaiterId = element.HeadwaiterId, - ConferenceBookingLunches = element.ConferenceBookingLunches - }); - - return true; - } - public bool Create(ConferenceBookingBindingModel model) { CheckModel(model); diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs index b73247c..523d57d 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogics/ConferenceLogic.cs @@ -58,38 +58,6 @@ namespace HotelBusinessLogic.BusinessLogics 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); diff --git a/Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs b/Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs index 0d5408d..7fb8f5a 100644 --- a/Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs +++ b/Hotel/HotelBusinessLogic/BusinessLogics/MealPlanLogic.cs @@ -58,38 +58,6 @@ namespace HotelBusinessLogic.BusinessLogics 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); diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs index 32f0827..626688c 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceBookingLogic.cs @@ -9,7 +9,6 @@ namespace HotelContracts.BusinessLogicsContracts { List? ReadList(ConferenceBookingSearchModel? model); ConferenceBookingViewModel? ReadElement(ConferenceBookingSearchModel model); - bool AddLunchToConferenceBooking(ConferenceBookingSearchModel model, ILunchModel lunch); bool Create(ConferenceBookingBindingModel model); bool Update(ConferenceBookingBindingModel model); bool Delete(ConferenceBookingBindingModel model); diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceLogic.cs index 9087010..38cdce6 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IConferenceLogic.cs @@ -9,7 +9,6 @@ namespace HotelContracts.BusinessLogicsContracts { List? ReadList(ConferenceSearchModel? model); ConferenceViewModel? ReadElement(ConferenceSearchModel model); - bool AddMemberToConference(ConferenceSearchModel model, IMemberModel member); bool Create(ConferenceBindingModel model); bool Update(ConferenceBindingModel model); bool Delete(ConferenceBindingModel model); diff --git a/Hotel/HotelContracts/BusinessLogicsContracts/IMealPlanLogic.cs b/Hotel/HotelContracts/BusinessLogicsContracts/IMealPlanLogic.cs index 356d384..7b14c31 100644 --- a/Hotel/HotelContracts/BusinessLogicsContracts/IMealPlanLogic.cs +++ b/Hotel/HotelContracts/BusinessLogicsContracts/IMealPlanLogic.cs @@ -9,7 +9,6 @@ namespace HotelContracts.BusinessLogicsContracts { List? ReadList(MealPlanSearchModel? model); MealPlanViewModel? ReadElement(MealPlanSearchModel model); - bool AddMemberToMealPlan(MealPlanSearchModel model, IMemberModel member); bool Create(MealPlanBindingModel model); bool Update(MealPlanBindingModel model); bool Delete(MealPlanBindingModel model); diff --git a/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs b/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs index 7a5a70a..8b36dc4 100644 --- a/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/ConferenceBookingViewModel.cs @@ -19,13 +19,5 @@ namespace HotelContracts.ViewModels public Dictionary ConferenceBookingLunches { get; set; } public Dictionary ConferenceConferenceBookings { get; set; } = new(); - public ConferenceBookingViewModel() { } - - [JsonConstructor] - public ConferenceBookingViewModel(Dictionary ConferenceBookingLunches, Dictionary ConferenceConferenceBookings) - { - this.ConferenceBookingLunches = ConferenceBookingLunches.ToDictionary(x => x.Key, x => x.Value as ILunchModel); - this.ConferenceConferenceBookings = ConferenceConferenceBookings.ToDictionary(x => x.Key, x => x.Value as IConferenceBookingModel); - } } } \ No newline at end of file diff --git a/Hotel/HotelContracts/ViewModels/ConferenceViewModel.cs b/Hotel/HotelContracts/ViewModels/ConferenceViewModel.cs index c589074..d19e698 100644 --- a/Hotel/HotelContracts/ViewModels/ConferenceViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/ConferenceViewModel.cs @@ -18,13 +18,5 @@ namespace HotelContracts.ViewModels public int OrganiserId { get; set; } public Dictionary ConferenceMembers { get; set; } = new(); - - public ConferenceViewModel() { } - - [JsonConstructor] - public ConferenceViewModel(Dictionary ConferenceMembers) - { - this.ConferenceMembers = ConferenceMembers.ToDictionary(x => x.Key, x => x.Value as IMemberModel); - } } } \ No newline at end of file diff --git a/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs b/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs index 7d24c48..4997bf6 100644 --- a/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs +++ b/Hotel/HotelContracts/ViewModels/MealPlanViewModel.cs @@ -19,14 +19,5 @@ namespace HotelContracts.ViewModels public Dictionary MealPlanMembers { get; set; } = new(); public Dictionary MealPlanRooms { get; set; } = new(); - - public MealPlanViewModel() { } - - [JsonConstructor] - public MealPlanViewModel(Dictionary MealPlanMembers, Dictionary MealPlanRooms) - { - this.MealPlanMembers = MealPlanMembers.ToDictionary(x => x.Key, x => x.Value as IMemberModel); - this.MealPlanRooms = MealPlanRooms.ToDictionary(x => x.Key, x => x.Value as IRoomModel); - } } } \ No newline at end of file diff --git a/Hotel/HotelDataBaseImplement/Models/Conference.cs b/Hotel/HotelDataBaseImplement/Models/Conference.cs index 8d66ac9..d830920 100644 --- a/Hotel/HotelDataBaseImplement/Models/Conference.cs +++ b/Hotel/HotelDataBaseImplement/Models/Conference.cs @@ -28,10 +28,8 @@ namespace HotelDataBaseImplement.Models { if (_conferenceMembers == null) { - using var context = new HotelDataBase(); - _conferenceMembers = Members.ToDictionary(x => x.MemberId, x => (context.Members - .FirstOrDefault(y => y.Id == x.MemberId)! as IMemberModel)); - } + _conferenceMembers = Members.ToDictionary(x => x.MemberId, x => (x.Member as IMemberModel)); + } return _conferenceMembers; } } diff --git a/Hotel/HotelDataBaseImplement/Models/ConferenceBooking.cs b/Hotel/HotelDataBaseImplement/Models/ConferenceBooking.cs index 2469d52..84c03be 100644 --- a/Hotel/HotelDataBaseImplement/Models/ConferenceBooking.cs +++ b/Hotel/HotelDataBaseImplement/Models/ConferenceBooking.cs @@ -27,11 +27,8 @@ namespace HotelDataBaseImplement.Models { if (_conferenceBookingLunches == null) { - using var context = new HotelDataBase(); - _conferenceBookingLunches = Lunches - .ToDictionary(x => x.LunchId, x => (context.Lunches - .FirstOrDefault(y => y.Id == x.LunchId)! as ILunchModel)); - } + _conferenceBookingLunches = Lunches.ToDictionary(x => x.LunchId, x => (x.Lunch as ILunchModel)); + } return _conferenceBookingLunches; } } diff --git a/Hotel/HotelDataBaseImplement/Models/MealPlan.cs b/Hotel/HotelDataBaseImplement/Models/MealPlan.cs index 6522e63..49a35c7 100644 --- a/Hotel/HotelDataBaseImplement/Models/MealPlan.cs +++ b/Hotel/HotelDataBaseImplement/Models/MealPlan.cs @@ -29,10 +29,8 @@ namespace HotelDataBaseImplement.Models { if (_mealPlanMembers == null) { - using var context = new HotelDataBase(); - _mealPlanMembers = Members.ToDictionary(x => x.MemberId, x => (context.Members - .FirstOrDefault(y => y.Id == x.MemberId)! as IMemberModel)); - } + _mealPlanMembers = Members.ToDictionary(x => x.MemberId, x => (x.Member as IMemberModel)); + } return _mealPlanMembers; } } diff --git a/Hotel/HotelRestApi/Controllers/ConferenceBookingController.cs b/Hotel/HotelRestApi/Controllers/ConferenceBookingController.cs index 3209675..089dba1 100644 --- a/Hotel/HotelRestApi/Controllers/ConferenceBookingController.cs +++ b/Hotel/HotelRestApi/Controllers/ConferenceBookingController.cs @@ -19,72 +19,55 @@ namespace HotelRestApi.Controllers _conferenceBooking = conferenceBooking; } - [HttpGet] - public List? GetConferenceBookingList(int headwaiterId) - { - try - { - return _conferenceBooking.ReadList(new ConferenceBookingSearchModel + [HttpGet] + public List? GetConferenceBookings(int? headwaiterId = null) + { + try + { + List res; + if (!headwaiterId.HasValue) { - HeadwaiterId = headwaiterId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка бронирования по конференции"); - throw; - } - } - - [HttpGet] - public ConferenceBookingViewModel? GetConferenceBookingById(int conferenceBookingId) - { - try - { - var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel - { - Id = conferenceBookingId - }); + res = _conferenceBooking.ReadList(null); + } + else + { + res = _conferenceBooking.ReadList(new ConferenceBookingSearchModel { HeadwaiterId = headwaiterId }); + } + foreach (var conferencebooking in res) + { + conferencebooking.ConferenceBookingLunches = null!; + } + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка бронирований по конференциям"); + throw; + } + } + [HttpGet] + public Tuple>? GetConferenceBooking(int conferencebookingId) + { + try + { + var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel { Id = conferencebookingId }); if (elem == null) { return null; } + var res = Tuple.Create(elem, elem.ConferenceBookingLunches.Select(x => x.Value.LunchName).ToList()); + res.Item1.ConferenceBookingLunches = null!; + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения бронирования по конференции по id={Id}", conferencebookingId); + throw; + } + } - return elem; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения по id={Id}", conferenceBookingId); - throw; - } - } - - [HttpGet] - public Tuple>>? GetConferenceBooking(int conferenceBookingId) - { - try - { - var elem = _conferenceBooking.ReadElement(new ConferenceBookingSearchModel - { - Id = conferenceBookingId - }); - - if (elem == null) - { - return null; - } - - return Tuple.Create(elem, elem.ConferenceBookingLunches.Select(x => Tuple.Create(x.Value.LunchName, x.Value.LunchPrice)).ToList()); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения по id={Id}", conferenceBookingId); - throw; - } - } - - [HttpPost] + [HttpPost] public void CreateConferenceBooking(ConferenceBookingBindingModel model) { try @@ -127,19 +110,5 @@ namespace HotelRestApi.Controllers throw; } } - - [HttpPost] - public void AddLunchToConferenceBooking(Tuple model) - { - try - { - _conferenceBooking.AddLunchToConferenceBooking(model.Item1, model.Item2); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка добавления обеда в бронирование по конференции."); - throw; - } - } } } diff --git a/Hotel/HotelRestApi/Controllers/ConferenceController.cs b/Hotel/HotelRestApi/Controllers/ConferenceController.cs index 15cf03c..20750df 100644 --- a/Hotel/HotelRestApi/Controllers/ConferenceController.cs +++ b/Hotel/HotelRestApi/Controllers/ConferenceController.cs @@ -2,6 +2,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.ViewModels; +using HotelDataBaseImplement.Models; using Microsoft.AspNetCore.Mvc; namespace HotelRestApi.Controllers @@ -19,59 +20,55 @@ namespace HotelRestApi.Controllers _conference = conference; } - [HttpGet] - public List? GetConferenceList(int organiserId) - { - try - { - return _conference.ReadList(new ConferenceSearchModel - { - OrganiserId = organiserId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка конференций"); - throw; - } - } + [HttpGet] + public List? GetConferences(int? organiserId = null) + { + try + { + List res; + if (!organiserId.HasValue) + { + res = _conference.ReadList(null); + } + else + { + res = _conference.ReadList(new ConferenceSearchModel { OrganiserId = organiserId }); + } + foreach (var conference in res) + { + conference.ConferenceMembers = null!; + } + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения конференций"); + throw; + } + } - [HttpGet] - public List? GetConferences() - { - try - { - return _conference.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка конференций"); - throw; - } - } + [HttpGet] + public Tuple>? GetConference(int conferenceId) + { + try + { + var elem = _conference.ReadElement(new ConferenceSearchModel { Id = conferenceId }); + if (elem == null) + { + return null; + } + var res = Tuple.Create(elem, elem.ConferenceMembers.Select(x => $"{x.Value.MemberSurname} {x.Value.MemberName} {x.Value.MemberPatronymic}").ToList()); + res.Item1.ConferenceMembers = null!; + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения конференции по id={Id}", conferenceId); + throw; + } + } - [HttpGet] - public Tuple>>? GetConference(int conferenceId) - { - try - { - var elem = _conference.ReadElement(new ConferenceSearchModel { Id = conferenceId }); - if (elem == null) - { - return null; - } - var members = elem.ConferenceMembers.Select(x => Tuple.Create($"{x.Value.MemberSurname} {x.Value.MemberName} {x.Value.MemberPatronymic}", x.Value.MemberPhoneNumber)).ToList(); - - return Tuple.Create(elem, members); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения конференции по id={Id}", conferenceId); - throw; - } - } - - [HttpPost] + [HttpPost] public void CreateConference(ConferenceBindingModel model) { try @@ -113,19 +110,5 @@ namespace HotelRestApi.Controllers throw; } } - - [HttpPost] - public void AddMemberToConference(Tuple model) - { - try - { - _conference.AddMemberToConference(model.Item1, model.Item2); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка добавления участника в конференцию."); - throw; - } - } } } diff --git a/Hotel/HotelRestApi/Controllers/LunchController.cs b/Hotel/HotelRestApi/Controllers/LunchController.cs index 2bab907..bc64b16 100644 --- a/Hotel/HotelRestApi/Controllers/LunchController.cs +++ b/Hotel/HotelRestApi/Controllers/LunchController.cs @@ -19,55 +19,43 @@ namespace HotelRestApi.Controllers _lunch = lunch; } - [HttpGet] - public List? GetLunchList(int headwaiterId) - { - try - { - return _lunch.ReadList(new LunchSearchModel + [HttpGet] + public List? GetLunches(int? headwaiterId = null) + { + try + { + if (!headwaiterId.HasValue) { - HeadwaiterId = headwaiterId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка обедов"); - throw; - } - } + return _lunch.ReadList(null); + } + return _lunch.ReadList(new LunchSearchModel + { + HeadwaiterId = headwaiterId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка обедов"); + throw; + } + } - [HttpGet] - public List? GetLunches() - { - try - { - return _lunch.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка обедов"); - throw; - } - } + [HttpGet] + public LunchViewModel GetLunch(int lunchId) + { + try + { + var elem = _lunch.ReadElement(new LunchSearchModel { Id = lunchId }); + return elem; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения обеда по id={Id}", lunchId); + throw; + } + } - [HttpGet] - public LunchViewModel? GetLunchById(int lunchId) - { - try - { - return _lunch.ReadElement(new LunchSearchModel - { - Id = lunchId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения обеда по id={Id}", lunchId); - throw; - } - } - - [HttpPost] + [HttpPost] public void CreateLunch(LunchBindingModel model) { try diff --git a/Hotel/HotelRestApi/Controllers/MealPlanController.cs b/Hotel/HotelRestApi/Controllers/MealPlanController.cs index 4933f15..a381bbc 100644 --- a/Hotel/HotelRestApi/Controllers/MealPlanController.cs +++ b/Hotel/HotelRestApi/Controllers/MealPlanController.cs @@ -3,6 +3,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.ViewModels; using HotelDataBaseImplement; +using HotelDataBaseImplement.Models; using Microsoft.AspNetCore.Mvc; namespace HotelRestApi.Controllers @@ -20,38 +21,46 @@ namespace HotelRestApi.Controllers _mealPlan = mealPlan; } - [HttpGet] - public List? GetMealPlanList(int organiserId) - { - try - { - return _mealPlan.ReadList(new MealPlanSearchModel - { - OrganiserId = organiserId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка планов питания"); - throw; - } - } - [HttpGet] - public Tuple>>? GetMealPlan(int mealPlanId) + public List? GetMealPlans(int? organiserId = null) + { + try + { + List res; + if (!organiserId.HasValue) + { + res = _mealPlan.ReadList(null); + } + else + { + res = _mealPlan.ReadList(new MealPlanSearchModel { OrganiserId = organiserId }); + } + foreach (var mealPlan in res) + { + mealPlan.MealPlanMembers = null!; + } + return res; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения конференций"); + throw; + } + } + + [HttpGet] + public Tuple>? GetMealPlan(int mealPlanId) { try { - using var context = new HotelDataBase(); var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId }); if (elem == null) { return null; } - - var members = elem.MealPlanMembers.Select(x => Tuple.Create(x.Value.MemberSurname, x.Value.MemberName, x.Value.MemberPatronymic, x.Value.MemberPhoneNumber)).ToList(); - - return Tuple.Create(elem, members); + var res = Tuple.Create(elem, elem.MealPlanMembers.Select(x => $"{x.Value.MemberSurname} {x.Value.MemberName} {x.Value.MemberPatronymic}").ToList()); + res.Item1.MealPlanMembers = null!; + return res; } catch (Exception ex) { @@ -102,19 +111,5 @@ namespace HotelRestApi.Controllers throw; } } - - [HttpPost] - public void AddMemberToMealPlan(Tuple model) - { - try - { - _mealPlan.AddMemberToMealPlan(model.Item1, model.Item2); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка добавления участника в план питания."); - throw; - } - } } } diff --git a/Hotel/HotelRestApi/Controllers/MemberController.cs b/Hotel/HotelRestApi/Controllers/MemberController.cs index ef2d430..f8ad40a 100644 --- a/Hotel/HotelRestApi/Controllers/MemberController.cs +++ b/Hotel/HotelRestApi/Controllers/MemberController.cs @@ -2,6 +2,7 @@ using HotelContracts.BusinessLogicsContracts; using HotelContracts.SearchModels; using HotelContracts.ViewModels; +using HotelDataBaseImplement.Models; using Microsoft.AspNetCore.Mvc; namespace HotelRestApi.Controllers @@ -19,41 +20,43 @@ namespace HotelRestApi.Controllers _member = member; } - [HttpGet] - public List? GetMemberList(int organiserId) - { - try - { - return _member.ReadList(new MemberSearchModel - { - OrganiserId = organiserId, - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка участников"); - throw; - } - } + [HttpGet] + public List? GetMembers(int? organiserId = null) + { + try + { + if (!organiserId.HasValue) + { + return _member.ReadList(null); + } + return _member.ReadList(new MemberSearchModel + { + OrganiserId = organiserId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка участников"); + throw; + } + } - [HttpGet] - public MemberViewModel? GetMember(int memberId) - { - try - { - return _member.ReadElement(new MemberSearchModel - { - Id = memberId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения участника по id={Id}", memberId); - throw; - } - } + [HttpGet] + public MemberViewModel GetMember(int lunchId) + { + try + { + var elem = _member.ReadElement(new MemberSearchModel { Id = lunchId }); + return elem; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения обеда по id={Id}", lunchId); + throw; + } + } - [HttpPost] + [HttpPost] public void CreateMember(MemberBindingModel model) { try diff --git a/Hotel/HotelRestApi/Controllers/RoomController.cs b/Hotel/HotelRestApi/Controllers/RoomController.cs index 4ed78ed..6443fd4 100644 --- a/Hotel/HotelRestApi/Controllers/RoomController.cs +++ b/Hotel/HotelRestApi/Controllers/RoomController.cs @@ -7,18 +7,18 @@ using Microsoft.AspNetCore.Mvc; namespace HotelRestApi.Controllers { - [Route("api/[controller]/[action]")] - [ApiController] - public class RoomController : Controller - { - private readonly ILogger _logger; - private readonly IRoomLogic _room; + [Route("api/[controller]/[action]")] + [ApiController] + public class RoomController : Controller + { + private readonly ILogger _logger; + private readonly IRoomLogic _room; - public RoomController(ILogger logger, IRoomLogic room) - { - _logger = logger; - _room = room; - } + public RoomController(ILogger logger, IRoomLogic room) + { + _logger = logger; + _room = room; + } [HttpGet] public List GetRooms(int? headwaiterId = null) @@ -26,18 +26,18 @@ namespace HotelRestApi.Controllers try { List res; - if (!headwaiterId.HasValue) - { - res = _room.ReadList(null); - } - else - { - res = _room.ReadList(new RoomSearchModel { HeadwaiterId = headwaiterId }); - } - foreach (var service in res) - { - service.RoomLunches = null; - } + if (!headwaiterId.HasValue) + { + res = _room.ReadList(null); + } + else + { + res = _room.ReadList(new RoomSearchModel { HeadwaiterId = headwaiterId }); + } + foreach (var service in res) + { + service.RoomLunches = null; + } return res; } catch (Exception ex) @@ -53,10 +53,10 @@ namespace HotelRestApi.Controllers try { var elem = _room.ReadElement(new RoomSearchModel { Id = roomId }); - if (elem == null) - { - return null; - } + if (elem == null) + { + return null; + } var res = Tuple.Create(elem, elem.RoomLunches.Select(x => x.Value.LunchName).ToList()); res.Item1.RoomLunches = null!; return res; @@ -69,46 +69,46 @@ namespace HotelRestApi.Controllers } [HttpPost] - public void CreateRoom(RoomBindingModel model) - { - try - { - _room.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания номера"); - throw; - } - } + public void CreateRoom(RoomBindingModel model) + { + try + { + _room.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания номера"); + throw; + } + } - [HttpPost] - public void UpdateRoom(RoomBindingModel model) - { - try - { - model.RoomLunches = null!; - _room.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления данных номера"); - throw; - } - } + [HttpPost] + public void UpdateRoom(RoomBindingModel model) + { + try + { + model.RoomLunches = null!; + _room.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления данных номера"); + throw; + } + } - [HttpPost] - public void DeleteRoom(RoomBindingModel model) - { - try - { - _room.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления номера"); - throw; - } - } - } + [HttpPost] + public void DeleteRoom(RoomBindingModel model) + { + try + { + _room.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления номера"); + throw; + } + } + } }