示例#1
0
 private IQueryable <MVPollSubmission> GetSubmissions(PollSubmissionCriteria criteria)
 {
     return(from submission in this.Entities.MVPollSubmissions
            where (submission.PollID == criteria.PollID &&
                   submission.UserID == criteria.UserID)
            select submission);
 }
示例#2
0
        private void DataPortal_Create(PollSubmissionCriteria criteria)
        {
            var existingSubmission = this.GetSubmissions(criteria).Any();

            if (existingSubmission)
            {
                throw new NotSupportedException("A user cannot vote on a poll more than once.");
            }

            this.FillFromPoll(criteria);
            this.BusinessRules.CheckRules();
        }
示例#3
0
        private void DataPortal_Fetch(PollSubmissionCriteria criteria)
        {
            using (this.BypassPropertyChecks)
            {
                this.FillFromPoll(criteria);

                var submission = GetSubmissions(criteria).FirstOrDefault();

                if (submission == null)
                {
                    return;
                }

                this.SubmissionDate = submission.PollSubmissionDate;

                foreach (var response in submission.MVPollResponses)
                {
                    this.Responses.Single(r => r.PollOptionID == response.PollOptionID)
                    .IsOptionSelected = response.OptionSelected;
                }
            }
        }
示例#4
0
        private void FillFromPoll(PollSubmissionCriteria criteria)
        {
            var poll = this.pollFactory.Fetch(criteria.PollID);
            var now  = DateTime.UtcNow;

            // The rules that will kick for the next three properties will set the active flag correctly;
            this.IsActive          = true;
            this.IsPollOwnedByUser = poll.UserID == criteria.UserID;
            this.PollDeletedFlag   = poll.PollDeletedFlag;
            this.PollStartDate     = poll.PollStartDate.Value;
            this.PollEndDate       = poll.PollEndDate.Value;
            this.CategoryName      = (from category in this.Entities.MVCategories
                                      where category.CategoryID == poll.PollCategoryID
                                      select category.CategoryName).Single();
            this.PollImageLink   = poll.PollImageLink;
            this.PollID          = criteria.PollID;
            this.UserID          = criteria.UserID;
            this.PollQuestion    = poll.PollQuestion;
            this.PollDescription = poll.PollDescription;
            this.PollMinAnswers  = poll.PollMinAnswers.Value;
            this.PollMaxAnswers  = poll.PollMaxAnswers.Value;
            this.Responses       = this.pollSubmissionResponsesFactory.CreateChild(poll.PollOptions);
        }