public T1 GetView(ApplicationDbContext db)
        {
            SurveyUserData       model = Parameters as SurveyUserData;
            SurveyUserDataReturn surveyUserDataReturn = new SurveyUserDataReturn();

            int id               = StringToValue.ParseInt(model.Id);
            int surveyPartId     = StringToValue.ParseInt(model.SectionId);
            int surveyQuestionId = StringToValue.ParseInt(model.QuestionId);

            SurveyPart             surveyPart             = db.T_SurveyPart.Where(sp => sp.SurveyId == id && sp.Id == surveyPartId).FirstOrDefault();
            List <SurveyQuestion>  surveyQuestions        = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id && sq.Id < surveyQuestionId).ToList();
            SurveyQuestion         surveyQuestion         = surveyQuestions[surveyQuestions.Count() - 1];
            SurveyPartTemplate     surveyPartTemplate     = db.T_SurveyPartTemplate.Find(surveyPart.SurveyPartTemplateId);
            SurveyQuestionTemplate surveyQuestionTemplate = db.T_SurveyQuestionTemplate.Find(surveyQuestion.SurveyQuestionTemplateId);

            surveyUserDataReturn.TotalSections  = db.T_SurveyPart.Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalQuestions = db.T_SurveyPart
                                                  .Join(db.T_SurveyQuestion,
                                                        sp => sp.Id, sq => sq.SurveyPartId,
                                                        (sp, sq) => sp).Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalSectionQuestions   = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).Count();
            surveyUserDataReturn.QuestionSectionNo       = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id && sq.Id <= surveyQuestion.Id).Count();
            surveyUserDataReturn.SectionName             = surveyPartTemplate.Name;
            surveyUserDataReturn.SectionTitle            = surveyPartTemplate.SummaryTitle;
            surveyUserDataReturn.SectionId               = surveyPart.Id;
            surveyUserDataReturn.QuestionId              = surveyQuestion.Id;
            surveyUserDataReturn.QuestionName            = surveyQuestionTemplate.Name;
            surveyUserDataReturn.QuestionDescription     = surveyQuestionTemplate.Definition;
            surveyUserDataReturn.QuestionType            = surveyQuestionTemplate.QuestionType;
            surveyUserDataReturn.QuestionEmployeeScore   = surveyQuestion.EmployeeScore;
            surveyUserDataReturn.QuestionEmployeeComment = surveyQuestion.EmployeeComment;
            surveyUserDataReturn.SectionNo               = db.T_SurveyPart.Where(sp => sp.SurveyId == id && sp.Id <= surveyPart.Id).Count();

            return(surveyUserDataReturn as T1);
        }
        public T1 GetView(ApplicationDbContext db)
        {
            SurveyUserData       model = Parameters as SurveyUserData;
            SurveyUserDataReturn surveyUserDataReturn = new SurveyUserDataReturn();
            SurveyPart           surveyPart           = new SurveyPart();

            int id = StringToValue.ParseInt(model.Id);

            surveyPart = db.T_SurveyPart.Where(sp => sp.SurveyId == id).FirstOrDefault();
            SurveyPartTemplate surveyPartTemplate = db.T_SurveyPartTemplate.Find(surveyPart.SurveyPartTemplateId);

            surveyUserDataReturn.TotalSections  = db.T_SurveyPart.Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalQuestions = db.T_SurveyPart
                                                  .Join(db.T_SurveyQuestion,
                                                        sp => sp.Id, sq => sq.SurveyPartId,
                                                        (sp, sq) => sp).Where(sp => sp.SurveyId == id).Count();
            surveyUserDataReturn.TotalSectionQuestions = db.T_SurveyQuestion.Where(sq => sq.SurveyPartId == surveyPart.Id).Count();
            surveyUserDataReturn.SectionName           = surveyPartTemplate.Name;
            surveyUserDataReturn.SectionTitle          = surveyPartTemplate.SummaryTitle;
            surveyUserDataReturn.SectionId             = surveyPart.Id;
            surveyUserDataReturn.QuestionId            = 0;
            surveyUserDataReturn.SectionNo             = db.T_SurveyPart.Where(sp => sp.SurveyId == id && sp.Id <= surveyPart.Id).Count();

            return(surveyUserDataReturn as T1);
        }
示例#3
0
        public JsonResult SectionHeaderView(SurveyUserData model)
        {
            IPrepareExtendedView <SurveyUserDataReturn, SurveyUserData> prepareStartSurveyView = new PrepareSectionHeaderView <SurveyUserDataReturn, SurveyUserData>();

            prepareStartSurveyView.Parameters = model;
            SurveyUserDataReturn surveyUserDataReturn = prepareStartSurveyView.GetView(_db);

            return(getResult(surveyUserDataReturn));
        }
示例#4
0
        public JsonResult FirstSectionQuestionView(SurveyUserData model)
        {
            IPrepareExtendedView <SurveyUserDataReturn, SurveyUserData> prepareExtendedView = new PrepareSectionPrevQuestionView <SurveyUserDataReturn, SurveyUserData>();

            prepareExtendedView.Parameters = model;
            SurveyUserDataReturn surveyUserDataReturn = prepareExtendedView.GetView(_db);

            return(getResult(surveyUserDataReturn));
        }
示例#5
0
        public JsonResult SectionHeader(SurveyUserData model)
        {
            ISaveModel <SurveyUserData> saveEmployeeSurveyScore = new SaveEmployeeSurveyScore <SurveyUserData>();

            saveEmployeeSurveyScore.Save(model, _db);

            IPrepareExtendedView <SurveyUserDataReturn, SurveyUserData> prepareStartSurveyView = new PrepareSectionHeaderView <SurveyUserDataReturn, SurveyUserData>();

            prepareStartSurveyView.Parameters = model;
            SurveyUserDataReturn surveyUserDataReturn = prepareStartSurveyView.GetView(_db);

            return(getResult(surveyUserDataReturn));
        }
示例#6
0
        public JsonResult CompleteSurveyn(SurveyUserData model)
        {
            ISaveModel <SurveyUserData> saveEmployeeSurveyScore = new SaveEmployeeSurveyScore <SurveyUserData>();

            saveEmployeeSurveyScore.Save(model, _db);

            ISaveModel <SurveyUserData> saveEmployeeSurveyComplete = new SaveEmployeeSurveyComplete <SurveyUserData>();

            saveEmployeeSurveyComplete.Save(model, _db);

            SurveyUserDataReturn surveyUserDataReturn = new SurveyUserDataReturn();

            return(getResult(surveyUserDataReturn));
        }
示例#7
0
        public void Save(T model, ApplicationDbContext db)
        {
            SurveyUserData surveyUserData = model as SurveyUserData;

            if (surveyUserData != null && surveyUserData.QuestionId != null && surveyUserData.QuestionId != "0")
            {
                Survey survey = db.T_Survey.Find(StringToValue.ParseInt(surveyUserData.Id));
                survey.CompliteEmployeeDate = DateTime.Now;
                survey.EmployeeCompleted    = true;
                survey.SurveyStatusId       = 2;

                db.Entry(survey).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
        public void Save(T model, ApplicationDbContext db)
        {
            SurveyUserData surveyUserData = model as SurveyUserData;

            if (surveyUserData != null && surveyUserData.QuestionId != null && surveyUserData.QuestionId != "0")
            {
                SurveyQuestion surveyQuestion = db.T_SurveyQuestion.Find(StringToValue.ParseInt(surveyUserData.QuestionId));
                surveyQuestion.EmployeeScore = StringToValue.ParseInt(surveyUserData.QuestionSelection);
                if (surveyUserData.QuestionEmployeeComment != null && surveyUserData.QuestionEmployeeComment != "")
                {
                    surveyQuestion.EmployeeComment = surveyUserData.QuestionEmployeeComment;
                }
                db.Entry(surveyQuestion).State = EntityState.Modified;
                db.SaveChanges();
            }
        }