public IActionResult CreateEvent(EventViewModel model, int[] RouteId) { if (ModelState.IsValid) { if (model.EventRoutes == null) { model.EventRoutes = new List <EventRouteViewModel>(); TimeZoneInfo localZone = TimeZoneInfo.Local; model.Timezone = localZone.Id; //model.EventDateTime } foreach (int id in RouteId) { SingleModelResponse <Route> routeResponse = _routeContext.GetRoute(id); if (routeResponse.DidError == true || routeResponse == null) { if (routeResponse == null) { return(View("Error")); } Error er = new Error(routeResponse.ErrorMessage); return(View("Error")); } model.EventRoutes.Add(routeResponse.Model.ToEventRouteViewModel()); } if (model.ClubId != 0) { SingleModelResponse <Club> clubResponse = _clubContext.GetClub(model.ClubId); if (clubResponse.DidError == true || clubResponse == null) { if (clubResponse == null) { return(View("Error")); } Error er = new Error(clubResponse.ErrorMessage); return(View("Error")); } model.ClubName = clubResponse.Model.Name; } //example of using cookie var CookieOption = new CookieOptions(); CookieOption.Expires = DateTime.Now.AddMinutes(5); CookieOption.HttpOnly = true; //set cookie HttpContext.Response.Cookies.Append("NewEvent", model.ToJson(), CookieOption); return(RedirectToAction("FinalizeEvent")); } else { return(View(model)); } }
public IActionResult EditRoute(int id) { SingleModelResponse <Route> routeResponse = _context.GetRoute(id); if (routeResponse.DidError == true || routeResponse == null) { if (routeResponse == null) { return(View("Error")); } Error er = new Error(routeResponse.ErrorMessage); return(View("Error")); } return(View(routeResponse.Model.ToRouteViewModel())); }