private static NotificationCollection SaveNewWaiter(WaiterViewModel viewModel, IMembershipService membershipService, IShifterSystem shifterSystem) { var notifications = NotificationCollection.CreateEmpty(); try { using (var scope = new TransactionScope()) { var createStatus = membershipService.CreateUser(viewModel.Waiter.EmailAddress, viewModel.Password, viewModel.Waiter.EmailAddress); if (createStatus == MembershipCreateStatus.Success) { notifications += CreateWaiterProfile(viewModel, shifterSystem, membershipService); } else { notifications.AddError(createStatus.ToString()); } scope.Complete(); } } catch (TransactionAbortedException ex) { notifications.AddError(ex.Message); } catch (ApplicationException ex) { notifications.AddError(ex.Message); } return(notifications); }
public WaiterViewModel GetWaiterViewModel(string userId) { var viewModel = new WaiterViewModel(); viewModel.NewOrders = this.GetOrdersWithStatus(ProcessType.Pending); viewModel.ActiveOrders = this.GetActiveOrders(userId); return(viewModel); }
private static NotificationCollection UpdateWaiter(WaiterViewModel viewModel, IMembershipService membershipService, IShifterSystem shifterSystem) { var notifications = NotificationCollection.CreateEmpty(); notifications += UpdatePassword(viewModel, membershipService); notifications += shifterSystem.WaiterService.SaveWaiter(viewModel.Waiter); return(notifications); }
public IActionResult Index(int index) { var waiterViewModel = new WaiterViewModel(); waiterViewModel.NumberOfRooms = _dataAccess.HotelRooms.GetNumberOfHotelRooms(); if (TempData["Room Index"] != null) { waiterViewModel.RoomIndex = (int)TempData["Room Index"]; TempData["success"] = "true"; } return(View(waiterViewModel)); }
//TODO this needs to be better public static NotificationCollection SaveWaiter(WaiterViewModel viewModel, IMembershipService membershipService, IShifterSystem shifterSystem) { var notifications = NotificationCollection.CreateEmpty(); if (viewModel.Waiter.IsNew()) { notifications += UpdateWaiter(viewModel, membershipService, shifterSystem); } else { notifications += SaveNewWaiter(viewModel, membershipService, shifterSystem); } return(notifications); }
public IActionResult Index(WaiterViewModel waiterViewModel) { if ((int)waiterViewModel.DisplayRoomNumbers.SelectedValue > 0) { waiterViewModel.Guests = _dataAccess.HotelRooms.GetReservationsForRoom(waiterViewModel.RoomIndex); } else { TempData["check"] = "false"; } waiterViewModel.NumberOfRooms = _dataAccess.HotelRooms.GetNumberOfHotelRooms(); waiterViewModel.RoomIndex = 0; return(View(waiterViewModel)); }
public IActionResult CheckIn(WaiterViewModel waiterViewModel, string btn) { var id = int.Parse(btn); foreach (var guest in waiterViewModel.Guests) { if (guest.GuestID == id) { _dataAccess.Guests.CheckIn(guest.GuestID); _dataAccess.Complete(); } } TempData["Room Index"] = waiterViewModel.Guests.SingleOrDefault(g => g.GuestID == id).HotelRoomID; return(RedirectToAction(nameof(Index))); }
private static NotificationCollection CreateWaiterProfile(WaiterViewModel viewModel, IShifterSystem shifterSystem, IMembershipService membershipService) { var notifications = NotificationCollection.CreateEmpty(); var userAccount = shifterSystem.UserService.LoadUser(viewModel.Waiter.EmailAddress); if (userAccount.IsNotNull()) { notifications += shifterSystem.WaiterService.SaveWaiter(viewModel.Waiter); if (notifications.HasErrors()) { membershipService.DeleteUser(userAccount.Username); } } return(notifications); }
private static NotificationCollection UpdatePassword(WaiterViewModel viewModel, IMembershipService membershipService) { var notifications = NotificationCollection.CreateEmpty(); try { var account = membershipService.LoadUser(viewModel.Waiter.EmailAddress); var currentPassword = account.GetPassword(); if (currentPassword != viewModel.Password) { account.ChangePassword(currentPassword, viewModel.Password); } } catch (Exception exception) { notifications.AddError(exception.Message); } return(notifications); }