Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public ActionResult Competitions()
        {
            var model = new CompetitionsVM(
                CompetitionService.GetAll()
                .OrderBy(x => x.WebSortOrder).IsActive());

            //            model.CurrentUserID = User.UserID;
            return(View(ViewNames.Competitions, model));
        }