public async Task <IHttpActionResult> PostContactInfo(ContactInfo contactInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await MessagingService.AddContactInfo(contactInfo); } catch (InvalidOperationException) { if (ContactInfoExists(contactInfo.ContactUsername, contactInfo.UserId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id1 = contactInfo.ContactUsername, id2 = contactInfo.UserId }, contactInfo)); }