예제 #1
0
        public PublicProfileVM GetPublic(int userID)
        {
            var user = UserService.GetByPK(userID);

            if (user == null)
            {
                return(null);
            }
            var currentUser = AuthService.CurrentUser;
            var tests       = new List <Test>();

            if (!user.HideCourses)
            {
                tests = UserTestService.GetAll(x => x.UserId == userID &&
                                               UserTestStatus.PassStatuses.Contains(x.Status)).OrderByDescending(x => x.RunDate)
                        .Select(x => x.Test).Distinct().ToList();
            }
            var model =
                new PublicProfileVM()
            {
                User          = user,
                IsExcelMaster = IsExcelMaster(user),
                IsOwner       = currentUser != null && currentUser.UserID == userID,
                Socials       = GetSocials(user.UserContacts)
                                .Where(x => !x.Contact.IsEmpty()).ToList(),
                SuccessStory = SuccessStoryService.GetAll()
                               .FirstOrDefault(ss => ss.UserID == user.UserID),
                Tests        = tests,
                Competitions = CompetitionService.GetAll()
                               .Where(c => c.WinnerID == user.UserID).ToList(),
                IsBest = IsBest(user),
            };

            return(model);
        }
        public static PublicProfileVM GetProfileVM(int userId)
        {
            PublicProfileVM result = new PublicProfileVM();

            switch (userId)
            {
            case 1:
                result.User    = UserService.GetUser1();
                result.Profile = GetProfile1();
                break;
            }

            return(result);
        }
예제 #3
0
        public ActionResult PublicProfile([FromUri] int id = 1)
        {
            PublicProfileVM vm = ProfileService.GetProfileVM(id);

            return(View(vm));
        }