Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using FooService.Data.BarServiceReference;
  2.  
  3. public class FooData : IFooData
  4. {
  5. public BarDto Func1(int id)
  6. {
  7. try
  8. {
  9. using (BarServiceClient client = new BarServiceClient())
  10. {
  11. return client.GetBar(id);
  12. }
  13. }
  14. catch (System.ServiceModel.FaultException ex)
  15. {
  16. throw new Exception($"Inner exception in BarServiceClient: { ex.Message }", ex);
  17. }
  18. }
  19. }
  20.  
  21. public class FooLogic
  22. {
  23. private IMapper Mapper { get; }
  24. private IFooData FooData { get; }
  25. public FooLogic(IMapper mapper, IFooData fooData)
  26. {
  27. Mapper = mapper;
  28. FooData = fooData;
  29. }
  30.  
  31. public Bar GetBar(int id)
  32. {
  33. BarDto barDto = FooData.Func1(itemId);
  34. Bar bar = Mapper.Map<BarDto, Bar>(barDto);
  35.  
  36. // There are lot more, taken from the Data layer.
  37. // Some operations are performed. The Bar is basically modified a little bit/adjusted
  38.  
  39.  
  40.  
  41. return bar;
  42. }
  43. }
Add Comment
Please, Sign In to add comment