Bookstore.ReviewsSearcher.ReviewsSearcherUI.WriteResultSet C# (CSharp) Method

WriteResultSet() static private method

static private WriteResultSet ( XmlTextWriter writer, ReviewsDAO reviewsDao, XmlNode queryNode ) : void
writer System.Xml.XmlTextWriter
reviewsDao Bookstore.DataAccessLayer.ReviewsDAO
queryNode System.Xml.XmlNode
return void
        static void WriteResultSet(XmlTextWriter writer, ReviewsDAO reviewsDao, XmlNode queryNode)
        {
            IEnumerable<FoundReviewTransferObject> foundReviews = null;
            string searchType = queryNode.Attributes["type"].InnerText;
            if (searchType == "by-period")
            {
                DateTime startDate = DateTime.Parse(
                    queryNode.SelectSingleNode("start-date").InnerXml);

                DateTime endDate = DateTime.Parse(
                    queryNode.SelectSingleNode("end-date").InnerXml);
                foundReviews = reviewsDao.GetReviewsByPeriod(startDate, endDate);
            }
            else if (searchType == "by-author")
            {
                string authorName = queryNode.SelectSingleNode("author-name")
                    .InnerXml.Trim().ToLower();
                foundReviews = reviewsDao.GetReviewsByAuthorName(authorName);
            }
            else
            {
                return;
            }

            writer.WriteStartElement("result-set");
            if (foundReviews != null)
            {
                foreach (var review in foundReviews)
                {
                    WriteFoundReview(writer, review);
                }
            }

            writer.WriteEndElement();
        }