public void OnGet() { CBS RequestDirector = new CBS(); var MemberNum = User.Claims.FirstOrDefault(c => c.Type == "MemberNumber").Value; Int32.TryParse(MemberNum, out int MemberNumber); StandingTeeTimeRequest = RequestDirector.FindStandingTeeTimeRequest(MemberNumber); if (StandingTeeTimeRequest.MemberNumber1 != MemberNumber) { TempData["Danger"] = true; Alert = $"You don't have a Standing Tee Time Request"; StandingTeeTimeRequest = null; } else { StartDate = StandingTeeTimeRequest.StartDate.ToString("yyyy-MM-dd"); EndDate = StandingTeeTimeRequest.EndDate.ToString("yyyy-MM-dd"); time = StandingTeeTimeRequest.Time.ToString("t"); TempData.Put("key", StandingTeeTimeRequest); } }
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")); } }