public ActionResult SecondStep() { var bookingVM = (BookingVM)TempData["Booking"]; foreach (var animal in bookingVM.Booking.Animals) { foreach (var accessoire in AnimalRepo.GetAnimal(animal.Id).Accessoires) { bookingVM.Accessoires.Add(accessoire); } } TempData["Booking"] = bookingVM; return(View(bookingVM)); }
public ActionResult FirstStep(AnimalBookingVM animalBookingVM) { ModelState.Remove("Animals"); ModelState.Remove("UnavailableAnimals"); var tempBooking = (BookingVM)TempData["Booking"]; animalBookingVM.BookingDate = tempBooking.Booking.BookingDate; if (!ModelState.IsValid) { animalBookingVM.Animals = AnimalRepo.GetAnimals(); animalBookingVM.UnavailableAnimals = new List <Animal>(); foreach (var animal in animalBookingVM.Animals) { foreach (var booking in animal.Bookings) { if (booking.BookingDate == tempBooking.Booking.BookingDate) { animalBookingVM.UnavailableAnimals.Add(animal); } } } animalBookingVM.BookingDate = tempBooking.Booking.BookingDate; TempData["Booking"] = tempBooking; return(View(animalBookingVM)); } foreach (var animalId in animalBookingVM.AnimalIds) { tempBooking.Booking.Animals.Add(AnimalRepo.GetAnimal(animalId)); } TempData["Booking"] = tempBooking; return(RedirectToAction("SecondStep")); }