public ActionResult BookService(BookedServiceMvcViewModel model) { if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage); return(RedirectToAction("Service", "Home", new { id = model.ServiceId, error = string.Join(", ", errors) })); } var service = Mapper.Map <BookedServiceDto>(model); var result = _serviceService.BookService(service); if (!result.Succeeded) { return(RedirectToAction("Service", "Home", new { id = model.ServiceId, error = "Не удалось заказать услугу." })); } return(RedirectToAction("Services", "Home")); }
public ActionResult Service(int id, string error) { var service = _serviceService.Get(id); if (service.Succeeded && string.IsNullOrEmpty(error)) { var model = new BookedServiceMvcViewModel { ServiceId = service.Data.Id, ServiceName = service.Data.Name, Price = service.Data.Price }; return(View("SingleService", model)); } return((string.IsNullOrEmpty(error)) ? (ActionResult)RedirectToAction("Services") : View("SingleService", new BookedServiceMvcViewModel { Error = error })); }