Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. class UpdateProductHandler
  2. {
  3. private readonly ISession session;
  4. public UpdateProductHandler(ISession session)
  5. {
  6. this.session = session;
  7. }
  8.  
  9. public async Task Update(int id, ProductIdentity productIdentity)
  10. {
  11. var product = session.Get(id);
  12. product.Update(productIdentity);
  13. }
  14. }
  15.  
  16. class GetProductHandler
  17. {
  18. private readonly ISession session;
  19. public GetProductHandler(ISession session)
  20. {
  21. this.session = session;
  22. }
  23.  
  24. public async Task<Product> Get(int id)
  25. {
  26. var product = session.Get(id);
  27. if (product == null)
  28. throw new Exception("Entity not found");
  29. return Task.FromResult(product);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement