Ejemplo n.º 1
0
        public void OnGet()
        {
            DateTime selectedtime = DateTime.Parse(Request.Query["time"]);
            DateTime selecteddate = DateTime.Parse(Request.Query["date"]);

            selectedteetime   = RequestDirector.FindTeeTime(selecteddate, selectedtime);
            authenticatedUser = UserManager.GetUser(UserManager.GetUserIdFromEmail(User.Identity.Name));
        }
Ejemplo n.º 2
0
        public ActionResult OnPost(string submit)
        {
            AuthenticatedUser = ClubBaistUsers.GetUserFromUserName(User.Identity.Name);
            SelectedDate      = DateTime.Parse(Request.Query["date"]);
            SelectedTime      = DateTime.Parse(Request.Query["time"]);

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

            SelectedTeeTime = _requestDirector.FindTeeTime(SelectedDate, SelectedTime);

            SelectedTeeTime.Golfer1.FullName = ReservedGolfer1Name;
            SelectedTeeTime.Golfer2.FullName = ReservedGolfer2Name;
            SelectedTeeTime.Golfer3.FullName = ReservedGolfer3Name;
            SelectedTeeTime.Golfer4.FullName = ReservedGolfer4Name;
            if (IsNullOrEmpty(SelectedTeeTime.BookerId) || SelectedTeeTime.BookerId == " " ||
                SelectedTeeTime.BookerId == "")
            {
                SelectedTeeTime.BookerId = AuthenticatedUser.Id;
            }

            var cancelledGolfers = new List <string>();

            switch (submit)
            {
            case "cancelForGolferOne":
                cancelledGolfers.Add(ReservedGolfer1Name);
                break;

            case "cancelForGolferTwo":
                cancelledGolfers.Add(ReservedGolfer2Name);
                break;

            case "cancelForGolferThree":
                cancelledGolfers.Add(ReservedGolfer3Name);
                break;

            case "cancelForGolferFour":
                cancelledGolfers.Add(ReservedGolfer4Name);
                break;

            case "cancelTeeTime":
                if (!IsNullOrEmpty(ReservedGolfer1Name))
                {
                    cancelledGolfers.Add(ReservedGolfer1Name);
                }
                if (!IsNullOrEmpty(ReservedGolfer2Name))
                {
                    cancelledGolfers.Add(ReservedGolfer2Name);
                }
                if (!IsNullOrEmpty(ReservedGolfer3Name))
                {
                    cancelledGolfers.Add(ReservedGolfer3Name);
                }
                if (!IsNullOrEmpty(ReservedGolfer4Name))
                {
                    cancelledGolfers.Add(ReservedGolfer4Name);
                }
                SelectedTeeTime.BookerId = " ";
                break;

            case "CheckInGolfers":
                SelectedTeeTime.Golfer1CheckedIn = ReservedGolfer1CheckedIn;
                SelectedTeeTime.Golfer2CheckedIn = ReservedGolfer2CheckedIn;
                SelectedTeeTime.Golfer3CheckedIn = ReservedGolfer3CheckedIn;
                SelectedTeeTime.Golfer4CheckedIn = ReservedGolfer4CheckedIn;
                break;
            }

            result = submit switch
            {
                "cancelForGolferOne" => _requestDirector.CancelTeeTime(SelectedTeeTime, cancelledGolfers),
                "cancelForGolferTwo" => _requestDirector.CancelTeeTime(SelectedTeeTime, cancelledGolfers),
                "cancelForGolferThree" => _requestDirector.CancelTeeTime(SelectedTeeTime, cancelledGolfers),
                "cancelForGolferFour" => _requestDirector.CancelTeeTime(SelectedTeeTime, cancelledGolfers),
                "cancelTeeTime" => _requestDirector.CancelTeeTime(SelectedTeeTime, cancelledGolfers),
                "Add" => _requestDirector.ReserveTeeTime(SelectedTeeTime),
                "CheckInGolfers" => _requestDirector.CheckInGolfers(SelectedTeeTime),
                _ => result
            };

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

            Alert = $"Modified TeeTime for {SelectedDate:dddd, dd MMMM yyyy} at {SelectedTime:hh:mm tt}";
            return(RedirectToPage("ReserveTeeTime"));
        }
        public ActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            getDatesForThisWeek();
            chosenTime    = DateTime.Parse(Request.Query["time"]);
            chosenDate    = DateTime.Parse(Request.Query["date"]);
            chosenteetime = RequestDirector.FindTeeTime(chosenDate, chosenTime);
            if (string.IsNullOrEmpty(chosenteetime.Player1.FullName) && string.IsNullOrEmpty(player1Name))
            {
                Alert = $"Please enter player 1 name to proceed!";
            }
            else if (chosenteetime.Player1.FullName != null && string.IsNullOrEmpty(chosenteetime.Player2.FullName) && string.IsNullOrEmpty(player2Name))
            {
                Alert = $"Please enter player 2 name to proceed!";
            }
            else if (chosenteetime.Player1.FullName != null && chosenteetime.Player2.FullName != null &&
                     string.IsNullOrEmpty(chosenteetime.Player3.FullName) &&
                     string.IsNullOrEmpty(player3Name))
            {
                Alert = $"Please enter player 3 to proceed!";
            }
            else if (chosenteetime.Player1.FullName != null && chosenteetime.Player2.FullName != null && chosenteetime.Player3.FullName != null &&
                     string.IsNullOrEmpty(chosenteetime.Player4.FullName) &&
                     string.IsNullOrEmpty(player4Name))
            {
                Alert = $"Please enter player 4 to proceed!";
            }
            else
            {
                // Assign the booker to TeeTime
                if (chosenteetime.BookerNumber == "" || chosenteetime.BookerNumber == " " ||
                    chosenteetime.BookerNumber == null)
                {
                    chosenteetime.BookerNumber = UserManager.GetUserIdFromEmail(User.Identity.Name);
                }

                if (chosenteetime.Player1 != null && player1Name != null)
                {
                    chosenteetime.Player1 = (Player)UserManager.GetUser(UserManager.GetUserId(player1Name));
                }
                if (chosenteetime.Player2 != null && player2Name != null)
                {
                    chosenteetime.Player2 = (Player)UserManager.GetUser(UserManager.GetUserId(player2Name));
                }
                if (chosenteetime.Player3 != null && player3Name != null)
                {
                    chosenteetime.Player3 = (Player)UserManager.GetUser(UserManager.GetUserId(player3Name));
                }
                if (chosenteetime.Player4 != null && player4Name != null)
                {
                    chosenteetime.Player4 = (Player)UserManager.GetUser(UserManager.GetUserId(player4Name));
                }
                Confirmation = RequestDirector.ReserveTeeTime(chosenteetime);

                if (Confirmation)
                {
                    Alert = $"Tee Time reserved successfully!";
                }
            }
            return(Page());
        }
Ejemplo n.º 4
0
        public IActionResult OnPostFind()
        {
            ModelState.Remove("Date");
            ModelState.Remove("Time");
            if (ModelState.IsValid)
            {
                Golfer golfer          = new Golfer();
                CBS    RequestDirector = new CBS();

                DateTime.TryParse(date, out DateTime selectedDate);

                if (selectedDate > DateTime.Today + TimeSpan.FromDays(7) || selectedDate < DateTime.Today)
                {
                    TempData["Danger"] = true;
                    if (selectedDate < DateTime.Today)
                    {
                        Alert = $"Cannot Modify a tee time for a passed date.";
                    }
                    else
                    {
                        Alert = $"Cannot Modify a tee time more than 7 days in advance.";
                    }

                    selectedTeeTime = null;
                    return(Page());
                }

                TimeSpan time = Convert.ToDateTime(selectedTime).TimeOfDay;
                //string[] Name = User.Identity.Name.Split(' ');
                //var


                //golfer.FirstName = Name[0];
                //golfer.LastName = Name[1];

                var LoggedInMember = User.Claims.FirstOrDefault(c => c.Type == "MemberNumber").Value;
                Int32.TryParse(LoggedInMember, out int loggedInMemNum);

                selectedTeeTime = RequestDirector.FindTeeTime(selectedDate, time);
                TempData.Put("selectedTeeTime", selectedTeeTime);

                if (selectedTeeTime.Time == null || selectedTeeTime.Date == null)
                {
                    selectedTeeTime    = null;
                    Alert              = $"Could Not find Tee Time for that date or time";
                    TempData["Danger"] = true;
                    return(RedirectToPage("/ModifyTeeTime"));
                }
                else if (selectedTeeTime.CreatedBy != loggedInMemNum)
                {
                    TempData["danger"] = true;
                    selectedTeeTime    = null;
                    Alert = $"You cannot modify a Tee Time you didn't create";
                    return(RedirectToPage("/ModifyTeeTime"));
                }
                else
                {
                    Golfer1 = selectedTeeTime.Golfer1;
                    Golfer2 = selectedTeeTime.Golfer2;
                    Golfer3 = selectedTeeTime.Golfer3;
                    Golfer4 = selectedTeeTime.Golfer4;
                    TempData.Put("key", selectedTeeTime);
                }
                //else if(selectedTeeTime.Golfer1 == User.Identity.Name || )
            }

            return(RedirectToPage("/ModifyTeeTime"));
        }