コード例 #1
0
 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));
     }
 }
コード例 #2
0
        public ActionResult Create(ContactDetailDto contact)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _contactApplicationService.CreateContact(contact);
                    return(RedirectToAction("Index"));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddValidationErrors(ex);
                }
            }

            return(View(contact));
        }
コード例 #3
0
        public OperationResult Post([FromBody] ContactDTO contact)
        {
            var result = _contactApplication.CreateContact(contact);

            return(result);
        }