//Metod som hämtar profilinfo när en användare är inloggad samt om profilen är aktiverad.
        public ActionResult ListProfileData()
        {
            var user = User.Identity.GetUserId();

            // Ser till att man inte kommer åt sidan om man är utloggad.
            if (user == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var ctx = new MVCDbContext();

            var profileActive = ctx.Profile.FirstOrDefault(p => p.ProfileId == user);

            //Kollar så att profilen inte är avaktiverad.
            if (!profileActive.IsActive)
            {
                return(RedirectToAction("EditProfileData", "Profile"));
            }

            // Lägger till de meddelanden vars mottagare är den inloggade användaren.
            var viewModel = new ImageIndexViewModel
            {
                Profiles = ctx.Profile.ToList(),
                Messages = ctx.Message.Where(m => m.RecieverId == user).ToList()
            };

            return(View(viewModel));
        }
Exemple #2
0
        //displays all images related to an account
        public ActionResult ProfileImageIndex()
        {
            Account account = GetAccount();
            IEnumerable <ProfileImage> images = profileImageDAL.FetchByAccount(account.accountID);
            ImageIndexViewModel        model  = new ImageIndexViewModel(images);

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> IndexAsync(string key)
        {
            var images = await _gameImageService.GetByGameKeyAsync(key);

            var imageViewModels = _mapper.Map <IEnumerable <GameImageViewModel> >(images);
            var viewModel       = new ImageIndexViewModel
            {
                GameKey = key,
                Images  = imageViewModels
            };

            return(View("Index", viewModel));
        }