PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/Songhay.Data.GenericWeb/Procedure/List/List.SearchForEdit.cs

http://GenericWeb.codeplex.com
C# | 37 lines | 30 code | 4 blank | 3 comment | 6 complexity | 341e03423de94ea7e07384f1972f4c9d MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.Common;
  5. using System.Xml.XPath;
  6. using Songhay.Data.GenericWeb.Properties;
  7. using Songhay.Xml;
  8. namespace Songhay.Data.GenericWeb.Procedure
  9. {
  10. /// <summary>
  11. /// List procedures for Web-schema data.
  12. /// </summary>
  13. internal static partial class List
  14. {
  15. internal static XPathDocument SearchForEdit(DbConnection commonConnection, IXPathNavigable navigableInput)
  16. {
  17. XPathNavigator n = XmlUtility.GetNavigableNode(navigableInput, "//SearchText");
  18. if(n == null) throw new Exception("SearchText node not found.");
  19. string s = string.Format("%{0}%", n.Value);
  20. if(commonConnection.State == ConnectionState.Open)
  21. {
  22. Dictionary<string, object> param = new Dictionary<string, object>(1);
  23. param.Add("@Search", s);
  24. s = Common.CommonScalar.GetString(commonConnection, Resources.Search, param);
  25. }
  26. if(string.IsNullOrEmpty(s))
  27. {
  28. return XmlUtility.GetInternalMessageDocument("Your Search Returned No Results", new string[] { string.Format("<strong>Search:</strong> <em>{0}</em>", n.Value) });
  29. }
  30. else return XmlUtility.GetNavigableDocument(s);
  31. }
  32. }
  33. }