예제 #1
0
        public IActionResult SavedRoutes()
        {
            ListModelResponse <Route> routeResponse = _context.GetUserRoutes(_userManager.GetUserId(User));

            if (routeResponse.DidError == true || routeResponse == null)
            {
                if (routeResponse == null)
                {
                    return(View("Error"));
                }
                Error er = new Error(routeResponse.ErrorMessage);
                return(View("Error"));
            }
            if (routeResponse.Model != null)
            {
                ViewBag.DistanceHighest = routeResponse.Model.OrderByDescending(p => p.Distance);
                ViewBag.DistanceLowest  = routeResponse.Model.OrderBy(p => p.Distance);
                ViewBag.Runs            = routeResponse.Model.OrderByDescending(p => p.RunCount);
                ViewBag.Events          = routeResponse.Model.OrderByDescending(p => p.EventCount);
            }
            string sourceCookie = HttpContext.Request.Cookies["SourcePageMap"];

            if (sourceCookie != null)
            {
                ViewBag.SourcePageMap = sourceCookie;
            }
            return(View(routeResponse.Model));
        }
예제 #2
0
        public IActionResult CreateEvent()
        {
            ListModelResponse <Route> routeResponse = _routeContext.GetUserRoutes(_userManager.GetUserId(User));

            if (routeResponse.DidError == true || routeResponse == null)
            {
                if (routeResponse == null)
                {
                    return(View("Error"));
                }
                Error er = new Error(routeResponse.ErrorMessage);
                return(View("Error"));
            }
            if (routeResponse.Model.Any())
            {
                ViewBag.UserRoutes = GetRoutes(null);
            }
            else
            {
                ViewBag.UserRoutes = null;
            }
            ListModelResponse <Club> clubResponse = _clubContext.GetUserClubs(_userManager.GetUserId(User));

            if (clubResponse.DidError == true || routeResponse == null)
            {
                if (routeResponse == null)
                {
                    return(View("Error"));
                }
                Error er = new Error(routeResponse.ErrorMessage);
                return(View("Error"));
            }
            if (clubResponse.Model.Any())
            {
                ViewBag.UserClubs = GetClubs(null);
            }
            else
            {
                ViewBag.UserClubs = null;
            }
            string         eventCookie = HttpContext.Request.Cookies["NewEvent"];
            EventViewModel model       = new EventViewModel();

            if (eventCookie != null)
            {
                model = eventCookie.FromJson <EventViewModel>();
            }

            return(View(model));
        }
예제 #3
0
        public IActionResult Default()
        {
            HomeViewModel             model         = new HomeViewModel();
            ListModelResponse <Event> routeResponse = _context.GetUserEvents(_userManager.GetUserId(User));

            if (routeResponse.DidError == true || routeResponse == null)
            {
                if (routeResponse == null)
                {
                    return(View("Error"));
                }
                Error er = new Error(routeResponse.ErrorMessage);
                return(View("Error"));
            }
            ListModelResponse <Route> eventResponse = _routeContext.GetUserRoutes(_userManager.GetUserId(User));

            if (eventResponse.DidError == true || eventResponse == null)
            {
                if (eventResponse == null)
                {
                    return(View("Error"));
                }
                Error er = new Error(eventResponse.ErrorMessage);
                return(View("Error"));
            }
            int nrEvents = eventResponse.Model.Count();
            int nrRoutes = routeResponse.Model.Count();

            model.NumberOfEvents = nrEvents;
            model.NumberOfRoutes = nrRoutes;
            return(View(model));
        }