コード例 #1
0
 public HttpResponseMessage Create(ContactInfoDetailDto contact)
 {
     try
     {
         _contactCrudService.CreateContactInfo(contact);
         return(Request.CreateResponse(HttpStatusCode.Created, contact));
     }
     catch (ValidationException ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
コード例 #2
0
        public ActionResult Create(ContactInfoDetailDto contactInfoDetailDto)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _contactCrudService.CreateContactInfo(contactInfoDetailDto);
                    return(RedirectToAction("Edit", "Contacts", new { id = contactInfoDetailDto.ContactId }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddValidationErrors(ex);
                }
            }

            return(View(contactInfoDetailDto));
        }