public object AddOrEdit(string schemaName, string tableName, [FromBody] JArray form) { dynamic user = form[0].ToObject <ExpandoObject>(JsonHelper.GetJsonSerializer()); var customFields = form[1].ToObject <List <CustomField> >(JsonHelper.GetJsonSerializer()); if (user == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.MethodNotAllowed)); } try { var repository = new FormRepository(schemaName, tableName, this.MetaUser.Tenant, this.MetaUser.LoginId, this.MetaUser.UserId); return(repository.AddOrEdit(user, customFields)); } catch (UnauthorizedException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } catch (DataAccessException ex) { throw new HttpResponseException(new HttpResponseMessage { Content = new StringContent(ex.Message), StatusCode = HttpStatusCode.InternalServerError }); } #if !DEBUG catch { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } #endif }