Beispiel #1
0
 public IActionResult ClubDetails(int id)
 {
     if (ModelState.IsValid)
     {
         SingleModelResponse <Club> clubResponse = _context.GetClub(id);
         if (clubResponse.DidError == true || clubResponse == null)
         {
             if (clubResponse == null)
             {
                 return(View("Error"));
             }
             Error er = new Error(clubResponse.ErrorMessage);
             return(View("Error", er));
         }
         ListModelResponse <ClubMember> membersResponse = _memberContext.GetClubMembers(clubResponse.Model.ClubId);
         if (membersResponse.DidError == true || membersResponse == null)
         {
             if (membersResponse == null)
             {
                 return(View("Error"));
             }
             Error er = new Error(membersResponse.ErrorMessage);
             return(View("Error", er));
         }
         ListModelResponse <Event> eventResponse = _eventContext.GetClubEvents(clubResponse.Model.ClubId);
         if (eventResponse.DidError == true || eventResponse == null)
         {
             if (eventResponse == null)
             {
                 return(View("Error"));
             }
             Error er = new Error(eventResponse.ErrorMessage);
             return(View("Error", er));
         }
         ViewBag.ClubMembers = membersResponse.Model;
         ViewBag.ClubEvents  = eventResponse.Model;
         string sourceCookie = HttpContext.Request.Cookies["SourcePageClub"];
         if (sourceCookie != null)
         {
             ViewBag.SourcePageClub = sourceCookie;
         }
         return(View(clubResponse.Model));
     }
     else
     {
         return(BadRequest());
     }
 }
Beispiel #2
0
        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));
            }
        }