Beispiel #1
0
        public ActionResult OnPost(string submit)
        {
            var authenticatedUser  = ClubBaistUsers.GetUserFromUserName(User.Identity.Name);
            var requestedDayOfWeek = Request.Query["day"];
            var requestedTime      = DateTime.Parse(Request.Query["time"]);
            var requestedStartDate = InputtedStartDate;
            var requestedEndDate   = InputtedEndDate;

            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var result = false;

            _selectedStandingTeeTimeRequest = _requestDirector.FindStandingTeeTimeRequest(requestedDayOfWeek,
                                                                                          requestedStartDate, requestedEndDate, requestedTime);
            _selectedStandingTeeTimeRequest.Shareholder1.FullName = InputtedShareholder1;
            _selectedStandingTeeTimeRequest.Shareholder2.FullName = InputtedShareholder2;
            _selectedStandingTeeTimeRequest.Shareholder3.FullName = InputtedShareholder3;
            _selectedStandingTeeTimeRequest.Shareholder4.FullName = InputtedShareholder4;

            if (IsNullOrEmpty(_selectedStandingTeeTimeRequest.BookerId) || _selectedStandingTeeTimeRequest.BookerId == " " ||
                _selectedStandingTeeTimeRequest.BookerId == "")
            {
                _selectedStandingTeeTimeRequest.BookerId = authenticatedUser.Id;
            }

            if (submit == "cancelStandingTeeTimeRequest")
            {
                _selectedStandingTeeTimeRequest.BookerId = " ";
            }

            result = submit switch
            {
                "submitStandingTeeTimeRequest" => _requestDirector.SubmitStandingTeeTimeRequest(_selectedStandingTeeTimeRequest),
                "cancelStandingTeeTimeRequest" => _requestDirector.CancelStandingTeeTimeRequest(_selectedStandingTeeTimeRequest),
                _ => result
            };

            if (!result)
            {
                return(Page());
            }

            Alert = $"Edited Standing Time for {requestedDayOfWeek} at {requestedTime:hh:mm tt}";
            return(RedirectToPage("SubmitStandingTeeTimeRequest"));
        }
    }
        public ActionResult OnPostCancel()
        {
            if (ModelState.IsValid)
            {
                Day      = Request.Query["day"].ToString();
                TimeSlot = DateTime.Parse(Request.Query["time"]);

                chosenstandingRequest =
                    RequestDirector.FindReservedStandingTeeTime(Day, TimeSlot, RequestedStartDate, RequestedEndDate);

                Confirmation = RequestDirector.CancelStandingTeeTimeRequest(chosenstandingRequest);

                if (Confirmation)
                {
                    Alert = $"Standing Tee Time Cancelled successfully!";

                    return(RedirectToPage("SubmitStandingTeeTime"));
                }
            }
            return(Page());
        }
Beispiel #3
0
        public IActionResult OnPostCancel()
        {
            if (ModelState.IsValid)
            {
                StandingTeeTimeRequest = TempData.Get <StandingTeeTime>("key");
                Confirmation           = false;
                CBS RequestDirector = new CBS();
                Confirmation = RequestDirector.CancelStandingTeeTimeRequest(StandingTeeTimeRequest.StandingTeeTimeID);
                if (Confirmation)
                {
                    TempData["Alert"] = $"Successfully Cancelled Standing Tee Time Request";
                    return(RedirectToPage("/Index"));
                }
                else
                {
                    TempData["Danger"] = true;
                    TempData["Alert"]  = $"Could Not Cancel Standing Tee Time Request";
                    RedirectToPage("/CancelStandingTeeTimeRequest");
                }
            }


            return(Page());
        }