public HttpResponseMessage Create(ContactDetailDto contact) { try { _contactApplicationService.CreateContact(contact); return(Request.CreateResponse(HttpStatusCode.Created, contact)); } catch (ValidationException ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public ActionResult Create(ContactDetailDto contact) { if (ModelState.IsValid) { try { _contactApplicationService.CreateContact(contact); return(RedirectToAction("Index")); } catch (ValidationException ex) { ModelState.AddValidationErrors(ex); } } return(View(contact)); }
public OperationResult Post([FromBody] ContactDTO contact) { var result = _contactApplication.CreateContact(contact); return(result); }