示例#1
0
        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);
        }
示例#2
0
        public WaiterViewModel GetWaiterViewModel(string userId)
        {
            var viewModel = new WaiterViewModel();

            viewModel.NewOrders    = this.GetOrdersWithStatus(ProcessType.Pending);
            viewModel.ActiveOrders = this.GetActiveOrders(userId);

            return(viewModel);
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        //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);
        }
示例#6
0
        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));
        }
示例#7
0
        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)));
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }