public ActionResult MakeBooking(BookingViewModel model, string apartmentClass) { try { if (ModelState.IsValid) { model.UserId = User.Identity.GetUserId(); if (apartmentClass == null) { ModelState.AddModelError("Empty class", "Empty apartment class field"); return(View(model)); } else if (apartmentClass == "Luxury") { model.ApartmentClassId = 1; } else if (apartmentClass == "Comfort") { model.ApartmentClassId = 2; } else if (apartmentClass == "Economy") { model.ApartmentClassId = 3; } var apartments = Mapper.Map <IEnumerable <ApartmentDTO>, IEnumerable <ApartmentViewModel> >(apartmentService.GetApartmentsForPickForBooking(Mapper.Map <BookingViewModel, BookingDTO>(model))); if (apartments.Count(a => a.Id > 0) == 0) { ViewBag.Error = "No free apartments for picked date"; return(View()); } BookingContainer.Date = model.DateOfArrival; BookingContainer.Days = model.DaysOfArrival; return(PartialView("ApartmentsPartial", apartments)); } } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); } return(View(model)); }