Ejemplo n.º 1
0
        public IActionResult MyPredictions()
        {
            string username = HttpContext.Session.GetString("Account");
            User   u        = UserRepo.GetUser(username);

            if (u != null)
            {
                List <Prediction> p      = repo.GetAllPredictions(u);
                List <Prediction> past   = new List <Prediction>();
                List <Prediction> future = new List <Prediction>();
                foreach (var prediction in p)
                {
                    if (prediction.Checked)
                    {
                        past.Add(prediction);
                    }
                    else
                    {
                        future.Add(prediction);
                    }
                }
                ViewBag.PastPredictions = past;
                ViewBag.MyPredictions   = future;
                return(View());
            }
            return(RedirectToAction("LogIn", "User"));
        }
Ejemplo n.º 2
0
        //PROFILE PAGE
        public IActionResult Profile(string username)
        {
            try
            {
                User u = repo.GetUser(username);
                if (u != null)
                {
                    u.Friends                    = repo.GetAcceptedFriends(u.ID);
                    ViewBag.LoggedInUser         = repo.GetUser(HttpContext.Session.GetString("Account"));
                    ViewBag.LoggedInUser.Friends = repo.GetAcceptedFriends(ViewBag.LoggedInUser.ID);

                    ViewBag.ProfileType = DetermineProfileType(u, ViewBag.LoggedInUser);
                    PredictionRepository tempRepo = new PredictionRepository(new PredictionRepositorySQLContext());
                    ViewBag.Predictions = tempRepo.GetAllPredictions(u);
                    return(View(u));
                }
                else
                {
                    return(View("UserNotFound"));
                }
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }