Exemple #1
0
        public static Boolean CheckProp(object PropVal, ViewQuestionAnswerModel objQuestionAnswerModel)
        {
            //    QuestionTypeModel objQuestionType = new QuestionTypeModel();

            if ((PropVal != null) && ((objQuestionAnswerModel.QuestionTypeDetail.SingleLineTextType != null && objQuestionAnswerModel.QuestionTypeDetail.SingleLineTextType.GetType() == PropVal.GetType()) ||
                                      (objQuestionAnswerModel.QuestionTypeDetail.MultiLineTextType != null && objQuestionAnswerModel.QuestionTypeDetail.MultiLineTextType.GetType() == PropVal.GetType()) ||
                                      (objQuestionAnswerModel.QuestionTypeDetail.NumberType != null && objQuestionAnswerModel.QuestionTypeDetail.NumberType.GetType() == PropVal.GetType()) ||
                                      (objQuestionAnswerModel.QuestionTypeDetail.SingleSelect != null && objQuestionAnswerModel.QuestionTypeDetail.SingleSelect.GetType() == PropVal.GetType()) ||
                                      (objQuestionAnswerModel.QuestionTypeDetail.MultiSelect != null && objQuestionAnswerModel.QuestionTypeDetail.MultiSelect.GetType() == PropVal.GetType())))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// TextBox
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="htmlHelper"></param>
        /// <param name="expression"></param>
        /// <param name="objQuestionAnswerModel"></param>
        /// <returns></returns>
        public static MvcHtmlString NumberTextBoxFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ViewQuestionAnswerModel objQuestionAnswerModel)
        {
            MvcHtmlString html    = default(MvcHtmlString);
            string        strHtml = "";

            if (objQuestionAnswerModel != null)
            {
                html    = System.Web.Mvc.Html.InputExtensions.TextBoxFor(htmlHelper, expression, GetAttributes(objQuestionAnswerModel));
                strHtml = html.ToHtmlString();
                string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
                var    properties    = typeof(NumberModel).GetProperties();
                strHtml += GetStringFromModel(objQuestionAnswerModel.QuestionTypeDetail.NumberType, properties, htmlFieldName);
            }
            else
            {
                html    = System.Web.Mvc.Html.InputExtensions.TextBoxFor(htmlHelper, expression);
                strHtml = html.ToHtmlString();
            }
            return(new MvcHtmlString(strHtml));
        }
Exemple #3
0
        private static RouteValueDictionary GetAttributes(ViewQuestionAnswerModel objQuestionAnswerModel)
        {
            var attributes = new RouteValueDictionary();
            //add form control class
            string cssClass = "form-control remove-bottom";

            //attributes["class"] = "form-control";


            if (Convert.ToBoolean(objQuestionAnswerModel.IsRequireResponse))
            {
                attributes["required"] = "required";
                //attributes["data-val-required"] = RepidShare.Entities.Resource.Response.valAnswer;
                attributes["data-val-required"] = "Answer is required.";

                attributes["data-val"] = "true";
            }

            if (objQuestionAnswerModel.QuestionPropertyList != null && objQuestionAnswerModel.QuestionPropertyList.Count > 0)
            {
                foreach (var queProperty in objQuestionAnswerModel.QuestionPropertyList)
                {
                    if (queProperty.PropertyText != null && queProperty.PropertyText.ToString().ToLower() == CommonUtils.QuestionProperty.MAX_CHAR.ToString().ToLower())
                    {
                        attributes["maxlength"] = queProperty.PropertyValue;
                    }

                    if (string.Compare(queProperty.PropertyText, CommonUtils.QuestionProperty.MIN_VALUE.ToString(), true) == 0)
                    {
                        attributes["data-val-length-min"] = queProperty.PropertyValue;
                        attributes["data-val"]            = "true";
                        attributes["questionid"]          = objQuestionAnswerModel.QuestionID;
                    }
                    if (string.Compare(queProperty.PropertyText, CommonUtils.QuestionProperty.MAX_VALUE.ToString(), true) == 0)
                    {
                        attributes["data-val-length-max"] = queProperty.PropertyValue;
                        attributes["data-val"]            = "true";
                    }
                    if (string.Compare(queProperty.PropertyText, CommonUtils.QuestionProperty.NO_OF_DECIMAL.ToString(), true) == 0)
                    {
                        if (Convert.ToInt32(queProperty.PropertyValue) > 0)
                        {
                            attributes["data-val-regex"]         = string.Format("Only {0} decimal place value accepted.", queProperty.PropertyValue);// "Price must can't have more than " + queProperty.PropertyValue + " decimal places";
                            attributes["data-val-regex-pattern"] = @"^(0|\d{0,30}(\.\d{0," + queProperty.PropertyValue + "})?)$";
                            cssClass += "numericDec";
                        }
                        else
                        {
                            cssClass += "numericInt";
                        }
                        attributes["id"] = "num_" + objQuestionAnswerModel.QuestionID;;
                    }

                    if (string.Compare(queProperty.PropertyText, CommonUtils.QuestionProperty.ISDATEONLY.ToString(), true) == 0)
                    {
                        cssClass += "pickDate form-control cal_icon dateTimePicker";
                        attributes["readonly"] = "readonly";
                    }
                    if (queProperty.PropertyText != null && queProperty.PropertyText.ToString().ToLower() == CommonUtils.QuestionProperty.NO_OF_LINES.ToString().ToLower())
                    {
                        attributes["rows"] = queProperty.PropertyValue;
                    }
                }
            }
            attributes["class"] = cssClass;
            if (objQuestionAnswerModel.QuestionType == CommonUtils.QuestionType.MultiLine.ToString())
            {
                //  attributes["onkeydown"] = "limitTextareaLine(this)";
                attributes["class"] += "yourtextarea";
                attributes["wrap"]   = "off";
                //  attributes["onkeyup"] = "foo(this,6)";
            }

            return(attributes);
        }
Exemple #4
0
        public static MvcHtmlString DropDownFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ViewQuestionAnswerModel objQuestionAnswerModel)
        {
            MvcHtmlString         html              = default(MvcHtmlString);
            string                strHtml           = "";
            List <SelectListItem> objSelectListItem = new List <SelectListItem>();

            StringReader theReader  = new StringReader("<XmlDS>" + objQuestionAnswerModel.DropDownXML + "</XmlDS>");
            DataSet      theDataSet = new DataSet();

            theDataSet.ReadXml(theReader);

            if (theDataSet != null && theDataSet.Tables.Count > 0)
            {
                foreach (DataRow item in theDataSet.Tables[0].Rows)
                {
                    objSelectListItem.Add(new SelectListItem
                    {
                        Text     = item["DropDownText"].ToString(),
                        Value    = item["QuestionDropDownID"].ToString(),
                        Selected = item["QuestionDropDownID"].ToString() == objQuestionAnswerModel.AnswerDetail ? true : false
                    });
                }
            }

            if (objQuestionAnswerModel != null)
            {
                html    = System.Web.Mvc.Html.SelectExtensions.DropDownListFor(htmlHelper, expression, objSelectListItem);
                strHtml = html.ToHtmlString();
                string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
                var    properties    = typeof(SingleLineModel).GetProperties();
                strHtml += GetStringFromModel(objQuestionAnswerModel.QuestionTypeDetail.DropDownType, properties, htmlFieldName);
            }
            else
            {
                html    = System.Web.Mvc.Html.SelectExtensions.DropDownListFor(htmlHelper, expression, objSelectListItem, new { @class = "form-control" });
                strHtml = html.ToHtmlString();
            }
            return(new MvcHtmlString(strHtml));
        }
Exemple #5
0
        public static MvcHtmlString AnswerRadioButtonFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ViewQuestionAnswerModel objQuestionAnswerModel, QuestionOptionsModel objQuestionOption, int optionIndex)
        {
            MvcHtmlString html          = default(MvcHtmlString);
            string        strHtml       = "";
            string        htmlFieldName = ExpressionHelper.GetExpressionText(expression);

            var properties = typeof(SingleSelectModel).GetProperties();

            if (objQuestionAnswerModel != null && objQuestionAnswerModel.QuestionOptionsList != null)
            {
                object model = htmlHelper.ViewData.Model;
                DocumentResponseDetailModel objModel = (DocumentResponseDetailModel)model;
                //for (int i = 0; i < objQuestionTypeModel.lstSingleSelection.Count(); i++)
                //{
                var Attributes = GetAttributes(objQuestionAnswerModel);

                Attributes["class"] += "radioanswer";
                Attributes.Add("id", "rdb_" + objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID + "_" + objModel.Questions[objModel.Index].QuestionID);
                Attributes.Add("Value", objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID);

                html = System.Web.Mvc.Html.InputExtensions.RadioButton(htmlHelper, "questionAnswer_" + objModel.Questions[objModel.Index].QuestionID,
                                                                       objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID, Attributes);
                //html = System.Web.Mvc.Html.InputExtensions.RadioButton(htmlHelper, "questionAnswer_" + objModel.Questions[objModel.Index].QuestionID,
                //    objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID,
                //    new
                //    {
                //        @class = "radioanswer",
                //        id = "rdb_" + objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID + "_" + objModel.Questions[objModel.Index].QuestionID,
                //        Value = objModel.Questions[objModel.Index].QuestionOptionsList[optionIndex].QuestionOptionsID
                //    });
                //html = System.Web.Mvc.Html.InputExtensions.RadioButton(htmlHelper, "rbSingle", objQuestionOption.OptionText, false, Attributes);
                strHtml += html.ToHtmlString();
                html     = System.Web.Mvc.Html.InputExtensions.HiddenFor(htmlHelper, expression);
                strHtml += html.ToHtmlString();
                strHtml += "<label>" + objQuestionOption.OptionText + "</label>";

                strHtml += GetStringFromModel(objQuestionAnswerModel.QuestionTypeDetail.SingleSelect, properties, htmlFieldName);
                // }
            }
            else
            {
                html    = System.Web.Mvc.Html.InputExtensions.RadioButtonFor(htmlHelper, expression, "");
                strHtml = html.ToHtmlString();
            }
            return(new MvcHtmlString(strHtml));
        }
Exemple #6
0
        /// <summary>
        /// TextBox
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="htmlHelper"></param>
        /// <param name="expression"></param>
        /// <param name="objQuestionAnswerModel"></param>
        /// <returns></returns>
        public static MvcHtmlString DateTimeTextBoxFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ViewQuestionAnswerModel objQuestionAnswerModel)
        {
            MvcHtmlString html    = default(MvcHtmlString);
            string        strHtml = "";

            if (objQuestionAnswerModel != null)
            {
                var    attrDate      = GetAttributes(objQuestionAnswerModel);
                string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
                object model         = htmlHelper.ViewData.Model;

                var index = ((DocumentResponseDetailModel)model).Index;


                /*---------------*/
                string DefaultDateTimeValue = null;
                //check value type is date or datet time
                if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.IsDateOnly == true)
                {
                    //check date is none,today or specific date
                    if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DefaultValueType == CommonUtils.DateDefaultValue.TodaysDate.ToString())
                    {
                        DefaultDateTimeValue = Convert.ToDateTime(System.DateTime.Now).ToString(CommonUtils.ShortDateFormat);
                    }
                    else if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DefaultValueType == CommonUtils.DateDefaultValue.SpecificDate.ToString())
                    {
                        DefaultDateTimeValue = Convert.ToDateTime(objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DateDefaultValue).ToString(CommonUtils.ShortDateFormat);
                    }
                }
                else if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.IsDateOnly == false)
                {
                    //check date is none,today or specific date
                    if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DefaultValueType == CommonUtils.DateDefaultValue.TodaysDate.ToString())
                    {
                        DefaultDateTimeValue = Convert.ToDateTime(System.DateTime.Now).ToString(CommonUtils.LongDateFormat);
                    }
                    else if (objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DefaultValueType == CommonUtils.DateDefaultValue.SpecificDate.ToString())
                    {
                        DefaultDateTimeValue = Convert.ToDateTime(objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DateDefaultValue).ToString(CommonUtils.LongDateFormat);
                    }
                }

                attrDate.Add("Value", string.IsNullOrWhiteSpace(((DocumentResponseDetailModel)model).Questions[index].AnswerDetail) ? DefaultDateTimeValue : ((DocumentResponseDetailModel)model).Questions[index].AnswerDetail);
                //attrDate.Add("Value", (
                //    objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DefaultValueType == CommonUtils.DateDefaultValue.SpecificDate.ToString() ?
                //    objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.IsDateOnly == true ?
                //    Convert.ToDateTime(objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DateDefaultValue).ToString(CommonUtils.ShortDateFormat)
                //    : Convert.ToDateTime(objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType.DateDefaultValue).ToString(CommonUtils.LongDateFormat)
                //    : ""));
                attrDate.Add("Id", "DatetimePicker_" + index);
                //// get the metdata
                //ModelMetadata fieldmetadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);

                ////// get the field name
                //var fieldName = ExpressionHelper.GetExpressionText(expression);

                ////// get full field (template may have prefix)
                //var fullName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);

                html = System.Web.Mvc.Html.InputExtensions.TextBoxFor(htmlHelper, expression, attrDate);

                strHtml = html.ToHtmlString();

                var properties = typeof(DateAndTimeModel).GetProperties();
                strHtml += GetStringFromModel(objQuestionAnswerModel.QuestionTypeDetail.DateAndTimeType, properties, htmlFieldName);
            }
            else
            {
                html    = System.Web.Mvc.Html.InputExtensions.TextBoxFor(htmlHelper, expression);
                strHtml = html.ToHtmlString();
            }
            return(new MvcHtmlString(strHtml));
        }
        /// <summary>
        /// Get  Document Response For view
        /// </summary>
        /// <param name="ObjDocumentApplicationMappingDetail"></param>
        /// <returns></returns>
        public DocumentResponseDetailModel GetDocumentResponseForView(DocumentResponseDetailModel objDocumentResponseDetailModel)
        {
            DLDocumentResponse objDLDocumentResponse = new DLDocumentResponse();
            //Get Document response detail with Document ,question , question property , question option and Document result.
            DataTable dtDocument = objDLDocumentResponse.GetDocumentResponseForView(objDocumentResponseDetailModel);

            if (dtDocument != null && dtDocument.Rows.Count > 0)
            {
                if (objDocumentResponseDetailModel != null)
                {
                    //fill Document master detail
                    int maxAttempt  = 0;
                    int noOfAttempt = 0;
                    int.TryParse(Convert.ToString(dtDocument.Rows[0]["MaxNoOfAttempt"]), out maxAttempt);
                    objDocumentResponseDetailModel.MaxNoOfAttempt = maxAttempt;

                    int.TryParse(Convert.ToString(dtDocument.Rows[0]["NoOfAttempt"]), out noOfAttempt);
                    objDocumentResponseDetailModel.NoOfAttempt = noOfAttempt;
                    //1. Fill Document detail  and application mapping detail

                    //objDocumentResponseDetailModel.DocumentApplicationDetail = GetDataRowToEntity<DocumentApplicationMappingModel>(dtDocument.Rows[0]);

                    //2. fill Document question details
                    objDocumentResponseDetailModel.Questions = new List <ViewQuestionAnswerModel>();

                    for (int i = 0; i < dtDocument.Rows.Count; i++)
                    {
                        ViewQuestionAnswerModel objQuestionModel = new ViewQuestionAnswerModel();
                        //get question from list
                        objQuestionModel = GetDataRowToEntity <ViewQuestionAnswerModel>(dtDocument.Rows[i]);

                        if (objQuestionModel != null && !objDocumentResponseDetailModel.Questions.Any(a => a.QuestionID == objQuestionModel.QuestionID))
                        {
                            DataView ViewQuestion = new DataView(dtDocument);
                            //Filter question into view
                            ViewQuestion.RowFilter = "QuestionID=" + objQuestionModel.QuestionID;
                            DataTable dtFilter = ViewQuestion.ToTable();
                            objQuestionModel.QuestionOptionsList  = new List <QuestionOptionsModel>();
                            objQuestionModel.QuestionPropertyList = new List <QuestionPropertyModel>();
                            for (int j = 0; j < dtFilter.Rows.Count; j++)
                            {
                                //fill question option detail
                                QuestionOptionsModel objQuestionOptionModel = new QuestionOptionsModel();
                                objQuestionOptionModel = GetDataRowToEntity <QuestionOptionsModel>(dtFilter.Rows[j]);
                                if (objQuestionOptionModel != null && objQuestionOptionModel.QuestionOptionsID > 0)
                                {
                                    objQuestionModel.QuestionOptionsList.Add(objQuestionOptionModel);
                                    //get detail of single/multi selection
                                    if (objQuestionOptionModel.IsSelected)
                                    {
                                        if (!String.IsNullOrWhiteSpace(objQuestionModel.SelectedAnswers))
                                        {
                                            objQuestionModel.SelectedAnswers = objQuestionModel.SelectedAnswers + "," + Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                        else
                                        {
                                            objQuestionModel.SelectedAnswers = Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                    }
                                }
                                //fill question property
                                QuestionPropertyModel objQuestionPropertyModel = new QuestionPropertyModel();
                                objQuestionPropertyModel = GetDataRowToEntity <QuestionPropertyModel>(dtFilter.Rows[j]);
                                if (objQuestionPropertyModel != null && !objQuestionModel.QuestionPropertyList.Any(a => a.QuestionTypeID == objQuestionPropertyModel.QuestionTypeID && a.QuestionPropertyID == objQuestionPropertyModel.QuestionPropertyID))
                                {
                                    objQuestionModel.QuestionPropertyList.Add(objQuestionPropertyModel);
                                }
                            }
                            objDocumentResponseDetailModel.Questions.Add(objQuestionModel);
                        }
                    }

                    //fill result detail
                    objDocumentResponseDetailModel.Result = GetDataRowToEntity <DocumentResultModel>(dtDocument.Rows[0]);

                    int totalRecord = Convert.ToInt32(dtDocument.Rows[0]["TotalCount"]);
                    //calculating total paging
                    objDocumentResponseDetailModel.TotalPages = TotalPage(totalRecord, objDocumentResponseDetailModel.PageSize);
                }
            }
            return(objDocumentResponseDetailModel);
        }
        /// <summary>
        /// Get Document response detail
        /// </summary>
        /// <param name="ObjDocumentApplicationMappingDetail"></param>
        /// <returns></returns>
        public DocumentResponseDetailModel GetDocumentPreview(DocumentResponseDetailModel objDocumentResponseDetailModel)
        {
            //objDocumentResponseDetailModel.DocumentApplicationDetail = new DocumentApplicationMappingModel();
            DLDocumentResponse objDLDocumentResponse = new DLDocumentResponse();
            //Get Document with question detail into datatable
            DataTable dtDocument = objDLDocumentResponse.GetDocumentPreview(objDocumentResponseDetailModel);

            if (dtDocument != null && dtDocument.Rows.Count > 0)
            {
                if (objDocumentResponseDetailModel != null)
                {
                    //1. Fill Document detail  and application mapping detail

                    //objDocumentResponseDetailModel.DocumentApplicationDetail = GetDataRowToEntity<DocumentApplicationMappingModel>(dtDocument.Rows[0]);

                    //2. fill Document question details
                    objDocumentResponseDetailModel.Questions = new List <ViewQuestionAnswerModel>();

                    for (int i = 0; i < dtDocument.Rows.Count; i++)
                    {
                        ViewQuestionAnswerModel objQuestionModel = new ViewQuestionAnswerModel();
                        //get question from list
                        objQuestionModel = GetDataRowToEntity <ViewQuestionAnswerModel>(dtDocument.Rows[i]);

                        if (objQuestionModel != null && !objDocumentResponseDetailModel.Questions.Any(a => a.QuestionID == objQuestionModel.QuestionID))
                        {
                            DataView ViewQuestion = new DataView(dtDocument);
                            ViewQuestion.RowFilter = "QuestionID=" + objQuestionModel.QuestionID;
                            DataTable dtFilter = ViewQuestion.ToTable();
                            objQuestionModel.QuestionOptionsList  = new List <QuestionOptionsModel>();
                            objQuestionModel.QuestionPropertyList = new List <QuestionPropertyModel>();
                            for (int j = 0; j < dtFilter.Rows.Count; j++)
                            {
                                //fill question option detail
                                QuestionOptionsModel objQuestionOptionModel = new QuestionOptionsModel();
                                objQuestionOptionModel = GetDataRowToEntity <QuestionOptionsModel>(dtFilter.Rows[j]);
                                if (objQuestionOptionModel != null && objQuestionOptionModel.QuestionOptionsID > 0)
                                {
                                    objQuestionModel.QuestionOptionsList.Add(objQuestionOptionModel);
                                    if (objQuestionOptionModel.IsSelected)
                                    {
                                        if (!String.IsNullOrWhiteSpace(objQuestionModel.SelectedAnswers))
                                        {
                                            objQuestionModel.SelectedAnswers = objQuestionModel.SelectedAnswers + "," + Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                        else
                                        {
                                            objQuestionModel.SelectedAnswers = Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                    }
                                }
                                //fill question property
                                QuestionPropertyModel objQuestionPropertyModel = new QuestionPropertyModel();
                                objQuestionPropertyModel = GetDataRowToEntity <QuestionPropertyModel>(dtFilter.Rows[j]);
                                if (objQuestionPropertyModel != null && !objQuestionModel.QuestionPropertyList.Any(a => a.QuestionTypeID == objQuestionPropertyModel.QuestionTypeID && a.QuestionPropertyID == objQuestionPropertyModel.QuestionPropertyID))
                                {
                                    objQuestionModel.QuestionPropertyList.Add(objQuestionPropertyModel);
                                }
                            }
                            objDocumentResponseDetailModel.Questions.Add(objQuestionModel);
                        }
                    }
                }
            }
            return(objDocumentResponseDetailModel);
        }
        /// <summary>
        /// Get  Document Response For Save
        /// </summary>
        /// <param name="ObjDocumentApplicationMappingDetail"></param>
        /// <returns></returns>
        public DocumentResponseDetailModel GetDocumentResponseForSave(DocumentResponseDetailModel objDocumentResponseDetailModel)
        {
            DLDocumentResponse objDLDocumentResponse = new DLDocumentResponse();
            //Get Document detail into datatable
            DataSet dtDocument = objDLDocumentResponse.GetDocumentResponseForSave(objDocumentResponseDetailModel);

            if (dtDocument != null && dtDocument.Tables.Count > 0 && dtDocument.Tables[0].Rows.Count > 0)
            {
                int totalRecord = Convert.ToInt32(dtDocument.Tables[0].Rows[0]["TotalCount"]);
                //calculating total paging
                objDocumentResponseDetailModel.TotalPages = TotalPage(totalRecord, 1);
                objDocumentResponseDetailModel.MaxPage    = Convert.ToInt32(dtDocument.Tables[0].Rows[0]["MaxPage"]);
            }
            if (dtDocument != null && dtDocument.Tables.Count > 1 && dtDocument.Tables[1].Rows.Count > 0)
            {
                if (objDocumentResponseDetailModel != null)
                {
                    //2. fill Document question details
                    objDocumentResponseDetailModel.Questions = new List <ViewQuestionAnswerModel>();

                    for (int i = 0; i < dtDocument.Tables[1].Rows.Count; i++)
                    {
                        ViewQuestionAnswerModel objQuestionModel = new ViewQuestionAnswerModel();
                        //get question from list
                        objQuestionModel = GetDataRowToEntity <ViewQuestionAnswerModel>(dtDocument.Tables[1].Rows[i]);

                        if (objQuestionModel != null && !objDocumentResponseDetailModel.Questions.Any(a => a.QuestionID == objQuestionModel.QuestionID))
                        {
                            DataView ViewQuestion = new DataView(dtDocument.Tables[1]);
                            //filter Document question into Data view by question id.
                            ViewQuestion.RowFilter = "QuestionID=" + objQuestionModel.QuestionID;
                            DataTable dtFilter = ViewQuestion.ToTable();
                            objQuestionModel.QuestionOptionsList  = new List <QuestionOptionsModel>();
                            objQuestionModel.QuestionPropertyList = new List <QuestionPropertyModel>();
                            for (int j = 0; j < dtFilter.Rows.Count; j++)
                            {
                                //fill question option detail

                                QuestionOptionsModel objQuestionOptionModel = new QuestionOptionsModel();
                                objQuestionOptionModel = GetDataRowToEntity <QuestionOptionsModel>(dtFilter.Rows[j]);
                                if (objQuestionOptionModel != null && objQuestionOptionModel.QuestionOptionsID > 0)
                                {
                                    objQuestionModel.QuestionOptionsList.Add(objQuestionOptionModel);
                                    if (objQuestionOptionModel.IsSelected)
                                    {
                                        //Set single and multi selection detail.
                                        if (!String.IsNullOrWhiteSpace(objQuestionModel.SelectedAnswers))
                                        {
                                            objQuestionModel.SelectedAnswers = objQuestionModel.SelectedAnswers + "," + Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                        else
                                        {
                                            objQuestionModel.SelectedAnswers = Convert.ToString(objQuestionOptionModel.QuestionOptionsID);
                                        }
                                    }
                                }
                                //fill question property
                                QuestionPropertyModel objQuestionPropertyModel = new QuestionPropertyModel();
                                objQuestionPropertyModel = GetDataRowToEntity <QuestionPropertyModel>(dtFilter.Rows[j]);
                                if (objQuestionPropertyModel != null && !objQuestionModel.QuestionPropertyList.Any(a => a.QuestionTypeID == objQuestionPropertyModel.QuestionTypeID && a.QuestionPropertyID == objQuestionPropertyModel.QuestionPropertyID))
                                {
                                    objQuestionModel.QuestionPropertyList.Add(objQuestionPropertyModel);
                                }
                            }
                            objDocumentResponseDetailModel.Questions.Add(objQuestionModel);
                        }
                    }

                    //fill Document result detail
                    objDocumentResponseDetailModel.Result = GetDataRowToEntity <DocumentResultModel>(dtDocument.Tables[1].Rows[0]);
                }
            }
            return(objDocumentResponseDetailModel);
        }