// GET api/contact public HttpResponseMessage Get() { var contacts = _contactServices.GetAllContacts(); var contactEntities = contacts as List <ContactEntity> ?? contacts.ToList(); if (contactEntities.Any()) { return(Request.CreateResponse(HttpStatusCode.OK, contactEntities)); } return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Contact not found")); }
public IHttpActionResult GetAllContacts() { var contacts = _ContactServices.GetAllContacts(); if (contacts != null) { var contactsEntities = contacts as List <ContactEntity> ?? contacts.ToList(); if (contactsEntities.Any()) { return(Ok(contactsEntities)); } } return(BadRequest("Contacts not found")); }