Exemple #1
0
        public ActionResult Resources()
        {
            // Gather all the pieces.

            var poll = _pollsQuery.GetActivePoll();

            var featuredArticles = _resourcesQuery.GetFeaturedArticles();
            var articles         = _resourcesQuery.GetArticles(from a in featuredArticles select a.ResourceId);

            var featuredVideo = _resourcesQuery.GetFeaturedVideos().Single();
            var video         = _resourcesQuery.GetVideo(featuredVideo.ResourceId);

            var featuredQnA = _resourcesQuery.GetFeaturedQnAs().Single();
            var qna         = _resourcesQuery.GetQnA(featuredQnA.ResourceId);

            return(View(new ResourcesModel
            {
                Categories = _resourcesQuery.GetCategories(),
                FeaturedArticles = featuredArticles.Select(r => new FeaturedArticleModel {
                    FeaturedResource = r, Article = articles.Single(a => a.Id == r.ResourceId)
                }).ToList(),
                FeaturedVideo = video,
                FeaturedQnA = qna,
                FeaturedQnAViews = qna != null ? _resourcesQuery.GetViewingCount(qna.Id) : 0,
                FeaturedQnAComments = qna != null ? _disqusQuery.GetCommentCount(qna.Id) ?? 0 : 0,
                ActivePoll = GetPollModel(poll),
            }));
        }
Exemple #2
0
        private HomeModel CreateHomeModel(UserType preferredUserType, Login login, MemberJoin join, bool acceptTerms)
        {
            var country = ActivityContext.Location.Country;

            var qna = _resourcesQuery.GetQnA(_resourcesQuery.GetFeaturedQnAs().Single().ResourceId);

            return(new HomeModel
            {
                PreferredUserType = preferredUserType,
                Login = login,
                Join = join,
                AcceptTerms = acceptTerms,
                Reference = new ReferenceModel
                {
                    MinSalary = JobAdSearchCriteria.MinSalary,
                    MaxSalary = JobAdSearchCriteria.MaxSalary,
                    StepSalary = JobAdSearchCriteria.StepSalary,
                    MinHourlySalary = JobAdSearchCriteria.MinHourlySalary,
                    MaxHourlySalary = JobAdSearchCriteria.MaxHourlySalary,
                    StepHourlySalary = JobAdSearchCriteria.StepHourlySalary,
                    Industries = GetIndustries(),
                    FeaturedStatistics = GetFeaturedStatistics(),
                    FeaturedEmployers = GetFeaturedEmployers(),
                    FeaturedJobAds = GetFeaturedJobAds(),
                    FeaturedCandidateSearches = GetFeaturedCandidateSearches(),
                    Countries = _locationQuery.GetCountries(),
                    CountrySubdivisions = (from s in _locationQuery.GetCountrySubdivisions(country) where !s.IsCountry select s).ToList(),
                    Regions = _locationQuery.GetRegions(country),
                    DefaultCountry = country,
                    FeaturedAnsweredQuestion = qna,
                    Categories = _resourcesQuery.GetCategories(),
                }
            });
        }
        protected override ResourceContent GetContent(Guid id, object cache)
        {
            // Look for the resource item.

            var article = _resourcesQuery.GetArticle(id);

            if (article != null)
            {
                return new ResourceContent {
                           Resource = article, Views = _resourcesQuery.GetViewingCount(id)
                }
            }
            ;

            var video = _resourcesQuery.GetVideo(id);

            if (video != null)
            {
                return new ResourceContent {
                           Resource = video, Views = _resourcesQuery.GetViewingCount(id)
                }
            }
            ;

            var qna = _resourcesQuery.GetQnA(id);

            if (qna != null)
            {
                return new ResourceContent {
                           Resource = qna, Views = _resourcesQuery.GetViewingCount(id)
                }
            }
            ;

            var faq = _faqsQuery.GetFaq(id);

            if (faq != null)
            {
                return new ResourceContent {
                           Resource = faq, Views = 0
                }
            }
            ;

            return(null);
        }
Exemple #4
0
        public ActionResult ViewAnsweredQuestion(Guid id)
        {
            try
            {
                var qna = _resourcesQuery.GetQnA(id);
                if (qna == null)
                {
                    return(JsonNotFound("QnA"));
                }

                var userId = CurrentMember == null ? CurrentAnonymousUser.Id : CurrentMember.Id;
                _resourcesCommand.ViewQnA(userId, qna.Id);
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            return(Json(new JsonResponseModel()));
        }