Guest User

Untitled

a guest
Jan 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public class UnitXmlConstructor : IEntityXmlConstructor
  2. {
  3. private readonly IHandbooksService _handbooksService;
  4. public UnitXmlConstructor(IHandbooksService handbooksService)
  5. {
  6. _handbooksService = handbooksService;
  7. }
  8.  
  9. public async Task<XElement> Construct(string id)
  10. {
  11. var units = _handbooksService.GetUnitsList(0, -1, null);
  12. var unit = units.Data.FirstOrDefault(c => c.Code == id);
  13. return new XElement("root",
  14. new XAttribute("Code", unit?.Code ?? ""),
  15. new XAttribute("Name", unit?.UnitName ?? ""));
  16. }
  17. }
  18.  
  19. public class BoolXmlConstructor : IEntityXmlConstructor
  20. {
  21. public BoolXmlConstructor()
  22. {
  23. }
  24.  
  25. public async Task<XElement> Construct(string value, object parameter)
  26. {
  27. bool logicValue = false;
  28. bool.TryParse(value, out logicValue);
  29. return new XElement("root",
  30. new XText(logicValue ? parameter?.ToString() ?? "" : ""));
  31. }
  32. }
Add Comment
Please, Sign In to add comment