public ActionResult EditPhoto(HttpRequestMessage request, PhotoVm photo) { try { Logger.Debug("Creating photo"); if (ModelState.IsValid) { if (photo.Id == 0) { _photoRepository.EditPhoto(photo); } else { _photoRepository.Updatephoto(photo); } return(new JsonResult()); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { validationErrors = GetErrorMessages() })); } catch (Exception ex) { var exceptionMessage = "Error creating photo"; Logger.Error(exceptionMessage, ex); Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { exceptionMessage })); } }