コード例 #1
0
 public CustomerCardRegistrationDataModel(Model contest, CustomerCardRegistrationModel userAnswers, bool isOfficial)
     : this(contest, isOfficial)
 {
     this.Questions = this.Questions.Select(x =>
     {
         var userAnswer = userAnswers.Questions.FirstOrDefault(y => y.QuestionId == x.Id);
         return new CustomerCardQuestionDataModel
         {
             //   Answer = userAnswer == null ? null : userAnswer.Answer,
             Id = x.Id,
             Text = x.Text
             //  Question = x.Question,
             //   Type = x.Type,
             //    PossibleAnswers = x.PossibleAnswers
         };
     });
 }
コード例 #2
0
        //IGeneralData regData = new GeneralData();
        public CustomerCardRegistrationDataModel(Model contest, bool isOfficial)
        {
            this.ContestId = contest.Id;

            if (isOfficial)
            {
                this.RequirePassword = contest.HasCustomerCardPassword;
            }

            //var data = this.regData.Data
            // .CustomerCardQuestions
            // .All()
            // .AsQueryable()
            // .Project()
            // .To<CustomerCardQuestionDataModel>();

            this.Questions = contest.Questions.AsQueryable().Select(c => Mapper.Map<Model, CustomerCardQuestionDataModel>(contest));
        }