public ActionResult Search(string txtSearch)
        {
            TempData["SearchText"] = txtSearch;

            esvWrapper wrapper = new esvWrapper("passageQuery", txtSearch, "crossway-xml-1.0");

            ViewBag.Notes = db.Notes.ToList();
            SearchResultsModel search = new SearchResultsModel();

            search = wrapper.getEsvXml();

            return View("SearchResults", search);
        }
Example #2
0
        public SearchResultsModel getEsvXml()
        {

            SearchResultsModel sr = new SearchResultsModel();
            using (var client = new HttpClient())
            {

                if (this.Passage.Length > 0)
                {
                    String xml = string.Empty;

                    xml = getESVPassage("&include-simple-entities=true");

                    // may want to change this to the original search text followed by a seperate call for the xml
                    // that way i have both cached in memory
                    sr.searchResults = xml;

                    XDocument xDoc = XDocument.Parse(xml);

                    //xDoc.Save(AppDomain.CurrentDomain.BaseDirectory.ToString() + @"\Gen1.xml");

                    var verses = (from v in xDoc.Descendants("verse-unit") select v);
                    StringBuilder sb = new StringBuilder();

                    var chapter = (from v in xDoc.Descendants("current") select v);

                    foreach(XElement c in chapter)
                    { sr.chapter = c.Value; }

                 


                    // below:
                    // instead of building verse html, i will build a verse model 
                    // and pass that model thru to the view for html parsing
                    foreach (XElement verse in verses)
                    {
                        sr.verses.Add(buildVerse(verse));
                    }
                    

                    // perform xml verse formatting prior to output.

                }

                return sr;

            }
        }