public ActionResult GetXmlList(bool editing)
        {
            var userId = GetUserID();

            if (editing)
            {
                var jobId   = GetJobCode();
                var context = new EightHundredEntities();//new HVAC_appContext();//
                var xml     = "";
                if (context.tbl_HVAC_CustomersAnswers.Any(item => item.JobID == jobId && item.UserID == userId))
                {
                    var customerAnswer =
                        context.tbl_HVAC_CustomersAnswers.First(item => item.JobID == jobId && item.UserID == userId);
                    xml = SetAnswers(context, customerAnswer);
                }
                else
                {
                    var customerAnswer = new tbl_HVAC_CustomersAnswers {
                        JobID = jobId, UserID = userId
                    };
                    context.tbl_HVAC_CustomersAnswers.AddObject(customerAnswer);
                    context.SaveChanges();
                    xml = SetAnswers(context, customerAnswer);
                }
                context.SaveChanges();
                return(new XmlResult(xml));
            }
            return(Json(new { result = 0 }));
        }
        private string SetAnswers(EightHundredEntities context, tbl_HVAC_CustomersAnswers customerAnswer)
        {
            //<?xml version='1.0' ?><data><action type='delete' sid='149' tid='149' ></action><action type='delete' sid='151' tid='151' ></action></data>
            var xml = "<?xml version='1.0' ?><data>";

            foreach (var num in Request.Form.Get("ids").Split(new[] { ',' }).Select(int.Parse))
            {
                var answerText = Request.Form.Get(num + "_answer");
                var answerData = Request.Form.Get(num + "_data");
                var status     = Request.Form.Get(num + "_!nativeeditor_status");
                xml += "<action type='" + status + "' sid='" + num + "' tid='" + num + "' ></action>";
                if (customerAnswer.tbl_HVAC_Answers.Any(item => item.QuestionID == num))
                {
                    var answer = customerAnswer.tbl_HVAC_Answers.Single(item => item.QuestionID == num);
                    if (status == "delete")
                    {
                        customerAnswer.tbl_HVAC_Answers.Remove(answer);
                    }
                    else
                    {
                        answer.Answer = answerText;
                        answer.Data   = answerData;
                    }
                }
                else
                {
                    if (status != "delete")
                    {
                        var answer = new tbl_HVAC_Answers
                        {
                            AnswerID   = customerAnswer.AnswerID,
                            QuestionID = num,
                            Answer     = answerText,
                            Data       = answerData
                        };
                        context.tbl_HVAC_Answers.AddObject(answer);
                    }
                }
            }
            xml += "</action></data>";
            return(xml);
        }