public JsonResult GetSegmentLRSDetails(int LRSId)
 {
     SegmentModel model = new SegmentModel();
     try
     {
         XMLService xml = new XMLService(_rtpProjectRepository);
         model.LRSRecord = xml.LoadRecord((int)SchemeName.LRSProjects, LRSId);
     }
     catch (Exception ex)
     {
         return Json(new { message = "LRS Record not found." });
     }
     return Json(model);
 }
 public JsonResult GetSegmentLRS(int segmentId)
 {
     SegmentModel model = new SegmentModel();
     try
     {
         model.LRSSchemeBase = _rtpProjectRepository.GetLRSScheme((int)SchemeName.LRSProjects);
         XMLService xml = new XMLService(_rtpProjectRepository);
         model._LRS = xml.LoadRecords((int)SchemeName.LRSProjects, segmentId);
     }
     catch (Exception ex)
     {
         return Json(new { message = "Segment not found." });
     }
     return Json(model);
 }
 public JsonResult GetSegmentDetails(int segmentId)
 {
     SegmentModel model;
     try
     {
         model = _rtpProjectRepository.GetSegmentDetails(segmentId);
         model.LRSSchemeBase = _rtpProjectRepository.GetLRSScheme((int)SchemeName.LRSProjects);
         XMLService xml = new XMLService(_rtpProjectRepository);
         model._LRS = xml.LoadRecords((int)SchemeName.LRSProjects, segmentId);
         //model._LRS = xml.LoadRecord((int)SchemeName.LRSProjects, segmentId);
         //var test = xml.GetScheme(1);
         //var temp = xml.GenerateXml(test,xml.GetSegmentLRSData(1, segmentId));
     }
     catch (Exception ex)
     {
         return Json(new { message = "Segment not found." });
     }
     return Json(model);
 }
        public JsonResult AddLRSRecord(SegmentModel model)
        {
            try
            {
                XMLService xml = new XMLService(_rtpProjectRepository);
                if (!String.IsNullOrEmpty(model.LRSRecordRaw))
                {
                    string data = xml.GenerateXml(xml.GetScheme((int)SchemeName.LRSProjects), new LRSRecord() { Columns = model.LRSRecordRaw.ToDictionary(',') });
                    model.LRSxml = data;

                    _rtpProjectRepository.AddLRSRecord(model);
                }
                else return Json(new { message = "Changes were not found. Refresh your page and try again." });

            }
            catch (Exception ex)
            {
                return Json(new { message = "Changes could not be stored. An error has been logged." });
            }
            return Json(new { message = "Segment successfully updated." });
        }
 public JsonResult GetSegmentDetails(int segmentId)
 {
     SegmentModel model;
     try
     {
         model = _surveyRepository.GetSegmentDetails(segmentId);
         XMLService xml = new XMLService(_surveyRepository);
         model._LRS = xml.LoadRecord((int)SchemeName.LRSProjects, model.LRSObjectID);
     }
     catch (Exception ex)
     {
         return Json(new { message = "Segment not found." });
     }
     return Json(model);
 }
        public JsonResult UpdateSegment(SegmentModel model)
        {
            try
            {
                XMLService xml = new XMLService(_surveyRepository);
                if (!String.IsNullOrEmpty(model.LRSRecord))
                {

                    string data = xml.GenerateXml(xml.GetScheme((int)SchemeName.LRSProjects), new LRSRecord() { Columns = model.LRSRecord.ToDictionary(',') });

                    model.LRSxml = data;
                }
                else model.LRSxml = xml.GenerateXml(null, null);

                _surveyRepository.UpdateSegment(model);
            }
            catch (Exception ex)
            {
                return Json(new { message = "Changes could not be stored. An error has been logged." });
            }
            return Json(new { message = "Segment successfully updated." });
        }