Esempio n. 1
0
        public ActionResult UsersThreadsListMap(string userName)
        {
            LoginUser user = _userService.GetByUserName(userName);

            if (user == null)
            {
                NotFound();
            }
            var listOfCords = UsersPostsLocation(userName);
            var model       = new MapModelList {
                Username = userName, MapCordsList = listOfCords
            };

            return(View(model));
        }
Esempio n. 2
0
        public IActionResult IndexAsync(string username)
        {
            LoginUser user = _userService.GetByUserName(username);

            if (user == null)
            {
                return(NotFound());
            }
            int?usersAch         = _service.GetUsersAchievement(user).Count(); //user's Achievements
            int totalAmountOfAch = _service.GetAllAchievements().Count();      //total amount of Achievements there is

            if (usersAch == null || totalAmountOfAch == 0)
            {
                return(NotFound());
            }

            //build model
            var model = _service.GetUsersAchievement(user).Select(achiev => new AchievementModel
            {
                Picture       = achiev.Achievement.Picture,
                Name          = achiev.Achievement.Name,
                Description   = achiev.Achievement.Description,
                Progress      = achiev.UsersProgress,
                ProgressLimit = achiev.MaxProgress,
                CompletedTime = achiev.CompletedTime,
                Completed     = achiev.Completed
            });

            var usersAchievementList = new AchievementModelList {
                AchievementLists = model
            };

            return(View(usersAchievementList));
        }
Esempio n. 3
0
        //Get request, View
        public async Task <IActionResult> Edit(int?threadId)
        {
            var       userName = _userManager.GetUserName(User); //gets the usersName
            LoginUser user     = _userService.GetByUserName(userName);
            var       userRole = await _userManager.GetRolesAsync(user);

            if (threadId == null)
            {
                return(NotFound());                     //check if the threadId is passed as a param
            }
            var thread = _service.GetById(threadId);    //gets the thread Id

            if (thread == null)
            {
                return(NotFound());                     //check if the thread is a real thread
            }
            //checks if the person accessing the thread is the owner
            if (userRole.Contains("Admin") || thread.UserName == userName)
            {
                var tags    = _service.GetThreadTags(thread);
                var tagline = "";
                foreach (var tag in tags)
                {
                    tagline += ",";
                    tagline += tag.Name;
                }
                if (tagline.Length != 0)
                {
                    tagline = tagline.Substring(1);
                }
                ViewData["Tags"] = tagline;

                return(View(thread));
            }
            if (thread.UserName != userName)
            {
                return(NotFound());
            }
            return(RedirectToAction("Index", "Thread", new { @id = threadId }));
        }
Esempio n. 4
0
        public async Task <IActionResult> Index(string username)
        {
            if (!_service.IfUserExists(username))
            {
                return(NotFound());
            }

            var user = _service.GetByUserName(username);

            if (user.ProfileImageUrl == null)
            {
                user.ProfileImageUrl = defaultAvatar;
            }
            //want a list of threads
            // threads will only display if you press your username when logged in button other wise it will not display the users threads
            var threads = BuildThreadList(username);
            //want a list of channels that the user is part of, tick
            var channels = BuildChannelsList(username);
            //calc the users Ratting
            var ratting = _service.GetRatting(username, threads);
            //list of all the users that the user follows
            var listOfFollower = _service.UsersFollowers(user);
            //user roles
            var userRoles = _userManager.GetRolesAsync(user);
            //gives the inital achievements to the user
            await _achievementService.AssignAchievementsToUser(user);

            //list of all the threads a user likes
            var likeList = _threadService.GetLikedThreads(user.Id);

            //list of all the users that follow the user
            var usersfollowing = _service.UserFollowingList(user);
            //list of users that the user follows
            var folllowingUsers = _service.ListOfFollowing(user);


            /*
             * Achievements HERE
             */
            //makes sure that the user is the user
            if (username == user.UserName)
            {
                await GiveUserLoginAch(user);
            }
            if (listOfFollower.Count() != _achievementService.FollowAchievementProgress(user) &&
                _achievementService.GetUsersAchievement(user).Count() != 0)
            {
                GiveTenFollowAch(user);
            }

            //build model
            var model = new ProfileModel()
            {
                Username        = user.UserName,
                UserId          = user.Id,
                UserRating      = ratting,
                Email           = user.Email,
                ProfileImageUrl = user.ProfileImageUrl,
                MemmberSince    = user.MemberSince,
                Threads         = threads,
                Channels        = channels,
                UsersFollowed   = usersfollowing,
                Warnings        = user.AccountWarnings,
                Roles           = userRoles,
                Likes           = likeList,
                FollowsUser     = folllowingUsers,
            };

            return(View(model));
        }