Example #1
0
        public IActionResult OnPost()
        {
            IActionResult actionResult = Page();

            if (ModelState.IsValid)
            {
                var result = _deskBookingRequestProcessor.BookDesk(DeskBookingRequest);

                if (result.Code == DeskBookingResultCode.Success)
                {
                    actionResult = RedirectToPage("BookDeskConfirmation", new
                    {
                        result.DeskBookingId,
                        result.FirstName,
                        result.Date
                    });
                }
                else if (result.Code == DeskBookingResultCode.NoDeskAvailable)
                {
                    ModelState.AddModelError("DeskBookingRequest.Date",
                                             "No desk availble for selected date");
                }
            }

            return(actionResult);
        }
Example #2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = _deskBookingRequestProcessor.BookDesk(DeskBookingRequest);

            if (result.Code == DeskBookingResultCode.NoDeskAvailabel)
            {
                ModelState.AddModelError("NoDeskAvailableINThatDate", "no Desk Available At this date");
                return(Page());
            }
            return(RedirectToPage("./Index"));
        }