예제 #1
0
        public List <SurveyTitle> GetTitles(int userId)
        {
            var                surveys      = _context.Surveys;
            var                users        = _userContext.Users.Find(userId);
            dynamic            surveys_left = JsonConvert.DeserializeObject(users.SurveysLeft);
            List <SurveyTitle> arr          = new List <SurveyTitle>();

            foreach (var title in surveys)
            {
                var titles = new SurveyTitle();
                titles.survey_id   = title.Survey_Id;
                titles.survey_name = title.Survey_Name;
                if (surveys_left == null)
                {
                    titles.survey_finished = true;
                }
                else
                {
                    foreach (var left in surveys_left)
                    {
                        if (left == title.Survey_Id)
                        {
                            titles.survey_finished = false;
                        }
                        else
                        {
                            titles.survey_finished = true;
                        }
                    }
                }
                arr.Add(titles);
            }
            return(arr);
        }
예제 #2
0
 public void MapFromEntity(SurveyTitle entity)
 {
     this.Id         = entity._id.ToString();
     this.Fitter     = entity.Fitter;
     this.CreateTime = entity.CreateTime;
     this.DeadLine   = entity.DeadLine;
     this.Name       = entity.Name;
 }
 public ActionResult Edit(SurveyTitleViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         SurveyTitle st = viewModel.MapToEntity();
         this.surveyService.UpdateSurvey(st);
         return(RedirectToAction("Details", viewModel));
     }
     else
     {
         ModelState.AddModelError("", "Some Error hanppend");
     }
     return(View());
 }
예제 #4
0
        public SurveyTitle MapToEntity()
        {
            SurveyTitle st  = new SurveyTitle();
            ObjectId    _id = ObjectId.GenerateNewId();

            if (!string.IsNullOrEmpty(this.Id))
            {
                if (!ObjectId.TryParse(this.Id, out _id))
                {
                    throw new ArgumentOutOfRangeException("id exception");
                }
            }
            st._id        = _id;
            st.CreateTime = this.CreateTime;
            st.DeadLine   = this.DeadLine;
            st.Fitter     = this.Fitter;
            st.Name       = this.Name;
            return(st);
        }
예제 #5
0
 public SurveyTitle UpdateSurvey(SurveyTitle entity)
 {
     return(this.surveyRepository.Update(entity));
 }
예제 #6
0
 public SurveyTitle CreateSurvey(SurveyTitle entity)
 {
     return(this.surveyRepository.Insert(entity));
 }