public object AddPermission([FromBody] string value) { APP_PERMISSION newPermission = null; try { newPermission = JsonConvert.DeserializeObject <APP_PERMISSION>(value); string executingUser = ""; APP_PERMISSION result = _service.AddPermission(newPermission); log.Info(string.Format("User {0} created New permission with the following data: \n\n{1}", executingUser, value)); return(Ok(result)); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { StringBuilder errmsg = new StringBuilder(); errmsg.Append(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State.ToString())); foreach (var ve in eve.ValidationErrors) { errmsg.Append(string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } log.Error(errmsg); } return(BadRequest("netApi.Controller.AddPermission(string) caused DbEntityValidationException!")); } catch (Exception e) { var msg = string.Format("Error Saving Permission Record.\n\nData:\n{0}.\n\n{1}", value, e.Message); log.Error(e); return(BadRequest(msg)); } }
public APP_PERMISSION AddPermission(APP_PERMISSION perm) { return(_repository.AddPermission(perm)); }