Example #1
0
        public HttpResponseMessage ListSurvey(string userName, int conferenceId, int conferenceSessionId = -1)
        {
            var account     = db.ACCOUNTs.SingleOrDefault(x => x.UserName == userName);
            var conference  = db.CONFERENCEs.SingleOrDefault(x => x.CONFERENCE_ID == conferenceId);
            var surveyModel = new ConferenceSurveyModel();

            if (account == null)
            {
                return(ResponseFail(StringResource.Account_does_not_exist));
            }
            else if (conference == null)
            {
                return(ResponseFail(StringResource.Conference_do_not_exist));
            }
            else
            {
                if (conferenceSessionId >= 0)
                {
                    var session = db.CONFERENCE_SESSION.SingleOrDefault(x => x.CONFERENCE_SESSION_ID == conferenceSessionId);
                    if (session == null)
                    {
                        return(ResponseFail(StringResource.Conference_session_do_not_exist));
                    }
                    else
                    {
                        List <MESSAGING_GROUP> groups = new MessageGroup().getListMessageGroup(userName);
                        var surveys = db.CONFERENCE_SURVEY.AsEnumerable()
                                      .Where(x => x.CONFERENCE_ID == conferenceId &&
                                             x.SURVEY_FOR_CONFERENCE_SESSION_ID == conferenceSessionId &&
                                             ((surveyModel.checkGroupsInSurvey(groups, x) || surveyModel.checkUserNameInSurvey(userName, x)) || x.PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY == "PUBLIC CONFERENCE SURVEY") &&
                                             (x.DELETED == false || x.DELETED == null))
                                      .ToList().AsEnumerable().Select(x => new
                        {
                            CONFERENCE_SURVEY_ID      = x.CONFERENCE_SURVEY_ID,
                            CONFERENCE_SURVEY_NAME    = x.CONFERENCE_SURVEY_NAME,
                            CONFERENCE_SURVEY_NAME_EN = x.CONFERENCE_SURVEY_NAME_EN,
                            DESCRIPTION                         = x.DESCRIPTION,
                            DESCRIPTION_EN                      = x.DESCRIPTION_EN,
                            CONFERENCE_ID                       = x.CONFERENCE_ID,
                            CONFERENCE_NAME                     = x.CONFERENCE_NAME,
                            CONFERENCE_NAME_EN                  = x.CONFERENCE_NAME_EN,
                            SAVED_UNCOMPLETED_ANSWERS           = x.SAVED_UNCOMPLETED_ANSWERS,
                            PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY = x.PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY,
                            SURVEY_FOR_CONFERENCE_SESSION_ID    = x.SURVEY_FOR_CONFERENCE_SESSION_ID,
                            COMPLETED_OR_UNCOMPLETED            = surveyModel.completeOrUnComplete(userName, x.CONFERENCE_SURVEY_ID)
                        }).ToList();
                        return(ResponseSuccess(StringResource.Success, surveys));
                    }
                }
                else
                {
                    List <MESSAGING_GROUP> groups = new MessageGroup().getListMessageGroup(userName);
                    var surveys = db.CONFERENCE_SURVEY.AsEnumerable()
                                  .Where(x => x.CONFERENCE_ID == conferenceId &&
                                         ((surveyModel.checkGroupsInSurvey(groups, x) || surveyModel.checkUserNameInSurvey(userName, x)) || (x.PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY == "PUBLIC CONFERENCE SURVEY" && x.SURVEY_FOR_CONFERENCE_SESSION_ID == null)) &&
                                         (x.DELETED == false || x.DELETED == null))
                                  .ToList().AsEnumerable().Distinct().Select(x => new
                    {
                        CONFERENCE_SURVEY_ID      = x.CONFERENCE_SURVEY_ID,
                        CONFERENCE_SURVEY_NAME    = x.CONFERENCE_SURVEY_NAME,
                        CONFERENCE_SURVEY_NAME_EN = x.CONFERENCE_SURVEY_NAME_EN,
                        DESCRIPTION                         = x.DESCRIPTION,
                        DESCRIPTION_EN                      = x.DESCRIPTION_EN,
                        CONFERENCE_ID                       = x.CONFERENCE_ID,
                        CONFERENCE_NAME                     = x.CONFERENCE_NAME,
                        CONFERENCE_NAME_EN                  = x.CONFERENCE_NAME_EN,
                        SAVED_UNCOMPLETED_ANSWERS           = x.SAVED_UNCOMPLETED_ANSWERS,
                        PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY = x.PUBLIC_OR_PRIVATE_CONFERENCE_SURVEY,
                        SURVEY_FOR_CONFERENCE_SESSION_ID    = x.SURVEY_FOR_CONFERENCE_SESSION_ID,
                        COMPLETED_OR_UNCOMPLETED            = surveyModel.completeOrUnComplete(userName, x.CONFERENCE_SURVEY_ID)
                    }).ToList();
                    return(ResponseSuccess(StringResource.Success, surveys));
                }
            }
        }
Example #2
0
        public HttpResponseMessage ListQuestion(string userName, int CONFERENCE_SURVEY_ID)
        {
            var survey = db.CONFERENCE_SURVEY.SingleOrDefault(x => x.CONFERENCE_SURVEY_ID == CONFERENCE_SURVEY_ID);

            if (survey == null)
            {
                return(ResponseFail(StringResource.Survey_do_not_exist));
            }
            else
            {
                if (survey.SAVED_UNCOMPLETED_ANSWERS == true)
                {
                    var model = new ConferenceSurveyModel();
                    var list  = db.CONFERENCE_SURVEY_QUESTION.AsEnumerable().Where(x => x.CONFERENCE_SURVEY_ID == CONFERENCE_SURVEY_ID && !model.questionIsComplete(userName, x.CONFERENCE_SURVEY_QUESTION_ID) && (x.DELETED == false || x.DELETED == null))
                                .ToList()
                                .OrderBy(x => x.CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER)
                                .Select(x => new
                    {
                        CONFERENCE_SURVEY_QUESTION_ID           = x.CONFERENCE_SURVEY_QUESTION_ID,
                        CONFERENCE_SURVEY_QUESTION1             = x.CONFERENCE_SURVEY_QUESTION1,
                        CONFERENCE_SURVEY_QUESTION_EN           = x.CONFERENCE_SURVEY_QUESTION_EN,
                        CONFERENCE_SURVEY_QUESTION_TYPE_NAME    = x.CONFERENCE_SURVEY_QUESTION_TYPE_NAME,
                        CONFERENCE_SURVEY_QUESTION_TYPE_NAME_EN = x.CONFERENCE_SURVEY_QUESTION_TYPE_NAME_EN,
                        CONFERENCE_SURVEY_ID      = x.CONFERENCE_SURVEY_ID,
                        CONFERENCE_SURVEY_NAME    = x.CONFERENCE_SURVEY_NAME,
                        CONFERENCE_SURVEY_NAME_EN = x.CONFERENCE_SURVEY_NAME_EN,
                        CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER = x.CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER,
                        CONFERENCE_SURVEY_QUESTION_OPTION_A     = x.CONFERENCE_SURVEY_QUESTION_OPTION_A,
                        CONFERENCE_SURVEY_QUESTION_POINT_A      = x.CONFERENCE_SURVEY_QUESTION_POINT_A,
                        CONFERENCE_SURVEY_QUESTION_OPTION_B     = x.CONFERENCE_SURVEY_QUESTION_OPTION_B,
                        CONFERENCE_SURVEY_QUESTION_POINT_B      = x.CONFERENCE_SURVEY_QUESTION_POINT_B,
                        CONFERENCE_SURVEY_QUESTION_OPTION_C     = x.CONFERENCE_SURVEY_QUESTION_OPTION_C,
                        CONFERENCE_SURVEY_QUESTION_POINT_C      = x.CONFERENCE_SURVEY_QUESTION_POINT_C,
                        CONFERENCE_SURVEY_QUESTION_OPTION_D     = x.CONFERENCE_SURVEY_QUESTION_OPTION_D,
                        CONFERENCE_SURVEY_QUESTION_POINT_D      = x.CONFERENCE_SURVEY_QUESTION_POINT_D,
                        CONFERENCE_SURVEY_QUESTION_OPTION_E     = x.CONFERENCE_SURVEY_QUESTION_OPTION_E,
                        CONFERENCE_SURVEY_QUESTION_POINT_E      = x.CONFERENCE_SURVEY_QUESTION_POINT_E,
                        CONFERENCE_SURVEY_QUESTION_OPTION_F     = x.CONFERENCE_SURVEY_QUESTION_OPTION_F,
                        CONFERENCE_SURVEY_QUESTION_POINT_F      = x.CONFERENCE_SURVEY_QUESTION_POINT_F,
                        CONFERENCE_SURVEY_QUESTION_OPTION_G     = x.CONFERENCE_SURVEY_QUESTION_OPTION_G,
                        CONFERENCE_SURVEY_QUESTION_POINT_G      = x.CONFERENCE_SURVEY_QUESTION_POINT_G,
                        CONFERENCE_SURVEY_QUESTION_OPTION_H     = x.CONFERENCE_SURVEY_QUESTION_OPTION_H,
                        CONFERENCE_SURVEY_QUESTION_POINT_H      = x.CONFERENCE_SURVEY_QUESTION_POINT_H,
                        MAXIMUM_RATING_SCALE_VALUE = x.MAXIMUM_RATING_SCALE_VALUE,
                        MINIMUM_RATING_SCALE_VALUE = x.MINIMUM_RATING_SCALE_VALUE,
                        RATING_SCALE_STEP_VALUE    = x.RATING_SCALE_STEP_VALUE,
                        CREATED_UserName           = x.CREATED_UserName,
                        CREATED_DATETIME           = x.CREATED_DATETIME,
                        LATEST_UPDATED_DATETIME    = x.LATEST_UPDATED_DATETIME,
                        DELETED          = x.DELETED,
                        DELETED_SCRIPT   = x.DELETED_SCRIPT,
                        DELETED_DATETIME = x.DELETED_DATETIME,
                        DELETED_UserName = x.DELETED_UserName
                    });
                    return(ResponseSuccess(StringResource.Success, list));
                }
                else
                {
                    var list = db.CONFERENCE_SURVEY_QUESTION.Where(x => x.CONFERENCE_SURVEY_ID == CONFERENCE_SURVEY_ID && (x.DELETED == false || x.DELETED == null))
                               .ToList()
                               .OrderBy(x => x.CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER)
                               .Select(x => new
                    {
                        CONFERENCE_SURVEY_QUESTION_ID           = x.CONFERENCE_SURVEY_QUESTION_ID,
                        CONFERENCE_SURVEY_QUESTION1             = x.CONFERENCE_SURVEY_QUESTION1,
                        CONFERENCE_SURVEY_QUESTION_EN           = x.CONFERENCE_SURVEY_QUESTION_EN,
                        CONFERENCE_SURVEY_QUESTION_TYPE_NAME    = x.CONFERENCE_SURVEY_QUESTION_TYPE_NAME,
                        CONFERENCE_SURVEY_QUESTION_TYPE_NAME_EN = x.CONFERENCE_SURVEY_QUESTION_TYPE_NAME_EN,
                        CONFERENCE_SURVEY_ID      = x.CONFERENCE_SURVEY_ID,
                        CONFERENCE_SURVEY_NAME    = x.CONFERENCE_SURVEY_NAME,
                        CONFERENCE_SURVEY_NAME_EN = x.CONFERENCE_SURVEY_NAME_EN,
                        CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER = x.CONFERENCE_SURVEY_QUESTION_ORDER_NUMBER,
                        CONFERENCE_SURVEY_QUESTION_OPTION_A     = x.CONFERENCE_SURVEY_QUESTION_OPTION_A,
                        CONFERENCE_SURVEY_QUESTION_POINT_A      = x.CONFERENCE_SURVEY_QUESTION_POINT_A,
                        CONFERENCE_SURVEY_QUESTION_OPTION_B     = x.CONFERENCE_SURVEY_QUESTION_OPTION_B,
                        CONFERENCE_SURVEY_QUESTION_POINT_B      = x.CONFERENCE_SURVEY_QUESTION_POINT_B,
                        CONFERENCE_SURVEY_QUESTION_OPTION_C     = x.CONFERENCE_SURVEY_QUESTION_OPTION_C,
                        CONFERENCE_SURVEY_QUESTION_POINT_C      = x.CONFERENCE_SURVEY_QUESTION_POINT_C,
                        CONFERENCE_SURVEY_QUESTION_OPTION_D     = x.CONFERENCE_SURVEY_QUESTION_OPTION_D,
                        CONFERENCE_SURVEY_QUESTION_POINT_D      = x.CONFERENCE_SURVEY_QUESTION_POINT_D,
                        CONFERENCE_SURVEY_QUESTION_OPTION_E     = x.CONFERENCE_SURVEY_QUESTION_OPTION_E,
                        CONFERENCE_SURVEY_QUESTION_POINT_E      = x.CONFERENCE_SURVEY_QUESTION_POINT_E,
                        CONFERENCE_SURVEY_QUESTION_OPTION_F     = x.CONFERENCE_SURVEY_QUESTION_OPTION_F,
                        CONFERENCE_SURVEY_QUESTION_POINT_F      = x.CONFERENCE_SURVEY_QUESTION_POINT_F,
                        CONFERENCE_SURVEY_QUESTION_OPTION_G     = x.CONFERENCE_SURVEY_QUESTION_OPTION_G,
                        CONFERENCE_SURVEY_QUESTION_POINT_G      = x.CONFERENCE_SURVEY_QUESTION_POINT_G,
                        CONFERENCE_SURVEY_QUESTION_OPTION_H     = x.CONFERENCE_SURVEY_QUESTION_OPTION_H,
                        CONFERENCE_SURVEY_QUESTION_POINT_H      = x.CONFERENCE_SURVEY_QUESTION_POINT_H,
                        MINIMUM_RATING_SCALE_VALUE = x.MINIMUM_RATING_SCALE_VALUE,
                        RATING_SCALE_STEP_VALUE    = x.RATING_SCALE_STEP_VALUE,
                        CREATED_UserName           = x.CREATED_UserName,
                        CREATED_DATETIME           = x.CREATED_DATETIME,
                        LATEST_UPDATED_DATETIME    = x.LATEST_UPDATED_DATETIME,
                        DELETED          = x.DELETED,
                        DELETED_SCRIPT   = x.DELETED_SCRIPT,
                        DELETED_DATETIME = x.DELETED_DATETIME,
                        DELETED_UserName = x.DELETED_UserName
                    });
                    return(ResponseSuccess(StringResource.Success, list));
                }
            }
        }