Beispiel #1
0
 public HttpResponseMessage Create(ContactDetailDto contact)
 {
     try
     {
         _contactCrudService.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
                {
                    _contactCrudService.CreateContact(contact);
                    return(RedirectToAction("Index"));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddValidationErrors(ex);
                }
            }

            return(View(contact));
        }