public async Task <IActionResult> OnPostSelectedTime(string interval, ScheduleViewModel schedule) { var currentLoggedInUserId = User.Claims.FirstOrDefault(x => x.Type == "sub").Value; var currentBooking = TempData.Get <BookingViewModel>(currentLoggedInUserId); var createBookingcommand = _mapper.Map <CreateBookingCommand>(currentBooking); createBookingcommand.IntervalId = Guid.Parse(interval); createBookingcommand.TransporterId = currentBooking.TransporterId; var result = await _bookingDataService.CreateBooking(createBookingcommand); if (result.IsSuccesfull) { return(RedirectToPage("confirm")); } ErrorMessage = "Der skete en fejl, prøv igen"; return(new RedirectToPageResult("")); }
public async Task <IActionResult> OnPostSelectedTime(string interval, ScheduleViewModel schedule) { var currentLoggedInUserId = GetLoggedInUserId(); // Get the current booking View Model from the session created at previous page var currentBooking = HttpContext.Session.GetObject <BookingViewModel>(currentLoggedInUserId); var createBookingcommand = _mapper.Map <CreateBookingCommand>(currentBooking); createBookingcommand.IntervalId = Guid.Parse(interval); createBookingcommand.TransporterId = Guid.Parse(currentLoggedInUserId); var result = await _bookingDataService.CreateBooking(createBookingcommand); if (result.IsSuccesfull) { return(RedirectToPage("confirm")); } ErrorMessage = "Der skete en fejl, prøv igen"; return(new RedirectToPageResult("")); }