Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ServiceContract]
- public class ContactsResource
- {
- private IContactRepository repository;
- public ContactsResource(IContactRepository repo)
- {
- this.repository=repo;
- }
- [WebGet(UriTemplate="")]
- public List<Contact> Get()
- {
- return repository.GetAll();
- }
- [WebInvoke(UriTemplate ="", Method="POST")]
- public HttpResponseMessage<Contact> Post(Contact contact)
- {
- repository.Post(contact);
- var response = new HttpResponseMessage<Contact>(contact);
- response.StatusCode = HttpStatusCode.Created;
- return response;
- }
- }
Add Comment
Please, Sign In to add comment