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();
}