Guest User

Untitled

a guest
Jan 12th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. [ServiceContract]
  2. public class ContactsResource
  3. {
  4. private IContactRepository repository;
  5.  
  6. public ContactsResource(IContactRepository repo)
  7. {
  8. this.repository=repo;
  9. }
  10.  
  11. [WebGet(UriTemplate="")]
  12. public List<Contact> Get()
  13. {
  14. return repository.GetAll();
  15. }
  16.  
  17. [WebInvoke(UriTemplate ="", Method="POST")]
  18. public HttpResponseMessage<Contact> Post(Contact contact)
  19. {
  20. repository.Post(contact);
  21. var response = new HttpResponseMessage<Contact>(contact);
  22. response.StatusCode = HttpStatusCode.Created;
  23. return response;
  24. }
  25. }
Add Comment
Please, Sign In to add comment