Example #1
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));
        }