Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. // Custom filters for App data sources and re-usable UI snippets in ServiceStack Templates pages
  2. public class ContactServiceFilters : TemplateFilter
  3. {
  4. internal readonly List<KeyValuePair<string, string>> MenuItems = new List<KeyValuePair<string, string>> {
  5. KeyValuePair.Create("/", "Home"),
  6. KeyValuePair.Create("/login-links", "Login Links"),
  7. KeyValuePair.Create("/register-links", "Register Links"),
  8. KeyValuePair.Create("/contact-links", "Contacts Links"),
  9. KeyValuePair.Create("/contact-edit-links", "Edit Contact Links"),
  10. };
  11.  
  12. public List<KeyValuePair<string, string>> menuItems() => MenuItems;
  13.  
  14. static Dictionary<string, string> Colors = new Dictionary<string, string> {
  15. {"#ffa4a2", "Red"},
  16. {"#b2fab4", "Green"},
  17. {"#9be7ff", "Blue"}
  18. };
  19.  
  20. public Dictionary<string, string> contactColors() => Colors;
  21.  
  22. private static List<KeyValuePair<string, string>> Titles => EnumUtils.GetValues<Title>()
  23. .Where(x => x != Title.Unspecified)
  24. .ToKeyValuePairs();
  25.  
  26. public List<KeyValuePair<string, string>> contactTitles() => Titles;
  27.  
  28. private static List<string> FilmGenres => EnumUtils.GetValues<FilmGenres>().Map(x => x.ToDescription());
  29. public List<string> contactGenres() => FilmGenres;
  30. }
  31.  
  32. // Razor Helpers for App data sources and re-usable UI snippets in Razor pages
  33. public static class RazorHelpers
  34. {
  35. internal static readonly ContactServiceFilters Instance = new ContactServiceFilters();
  36.  
  37. public static Dictionary<string, string> ContactColors(this IHtmlHelper html) => Instance.contactColors();
  38. public static List<KeyValuePair<string, string>> ContactTitles(this IHtmlHelper html) => Instance.contactTitles();
  39. public static List<string> ContactGenres(this IHtmlHelper html) => Instance.contactGenres();
  40. public static List<KeyValuePair<string, string>> MenuItems(this IHtmlHelper html) => Instance.MenuItems;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement