public ActionResult ShowSummary(ShowSummaryViewModel viewModel) { try { if (ModelState.IsValid) { GuestItineraryPoint startPoint = itinerarryService.GetBydId(1); GuestItineraryPoint endPoint = itinerarryService.GetBydId(int.Parse(viewModel.ItineraryPointId)); var summaryInfo = itinerarryService.ShowSummary(startPoint, endPoint); summaryInfo?.ForEach(summaryInfoItem => { SummaryPointInfoViewModel summaryPointViewmodel = new SummaryPointInfoViewModel(); mapper.Map(summaryInfoItem, summaryPointViewmodel); viewModel.SummaryInfoResults.Add(summaryPointViewmodel); }); } } catch { } Populate(viewModel); return(View(viewModel)); }
public ActionResult CreateItineraryRequest(GuestItineraryRequestViewModel viewModel) { try { Guest guest = guestService.GetById(int.Parse(viewModel?.GuestId)); GuestItineraryPoint endPoint = itinerarryService.GetBydId(int.Parse(viewModel?.ItineraryPointId)); if (endPoint?.Guests.Any(item => item.Id == guest.Id) == true) { ModelState.AddModelError(nameof(GuestItineraryRequestViewModel.GuestId), "Este huésped ya ha solicitado viajar al punto de interés selecionado"); } if (ModelState.IsValid) { endPoint.Guests.Add(guest); requestService.Save(new GuestItineraryRequest() { EndPoint = endPoint }); return(RedirectToAction("Index", "Home")); } } catch { } Populate(viewModel); return(View(viewModel)); }