diff --git a/server/AyaNova/Controllers/AttachmentController.cs b/server/AyaNova/Controllers/AttachmentController.cs index dbb3bc59..408c42dd 100644 --- a/server/AyaNova/Controllers/AttachmentController.cs +++ b/server/AyaNova/Controllers/AttachmentController.cs @@ -225,7 +225,7 @@ namespace AyaNova.Api.Controllers try { if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", $"Expected a multipart request, but got {Request.ContentType}")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}")); var uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext); @@ -357,7 +357,7 @@ namespace AyaNova.Api.Controllers } catch (InvalidDataException ex) { - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", ex.Message)); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message)); } //Return the list of attachment ids and filenames diff --git a/server/AyaNova/Controllers/DataListController.cs b/server/AyaNova/Controllers/DataListController.cs index 150aee70..e1903f4c 100644 --- a/server/AyaNova/Controllers/DataListController.cs +++ b/server/AyaNova/Controllers/DataListController.cs @@ -82,7 +82,7 @@ namespace AyaNova.Api.Controllers } catch (System.ArgumentOutOfRangeException e) { - return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "DataListKey", e.Message)); + return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, e.Message)); } } @@ -115,7 +115,7 @@ namespace AyaNova.Api.Controllers //was the name not found as a list? if (DataList == null) { - return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "DataListKey", $"DataList \"{DataListKey}\" specified does not exist")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, $"DataList \"{DataListKey}\" specified does not exist")); } return Ok(ApiOkResponse.Response(DataList.FieldDefinitions)); diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs index f3ccfc13..c946c481 100644 --- a/server/AyaNova/Controllers/NotifyController.cs +++ b/server/AyaNova/Controllers/NotifyController.cs @@ -101,7 +101,7 @@ namespace AyaNova.Api.Controllers if (n == null) return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "id")); if (n.UserId != UserId) - return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_AUTHORIZED, "UserId", "Can't delete notification for another user")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_AUTHORIZED, null, "Can't delete notification for another user")); ct.Notification.Remove(n); await ct.SaveChangesAsync(); return NoContent(); diff --git a/server/AyaNova/Controllers/PickListController.cs b/server/AyaNova/Controllers/PickListController.cs index aa2cba91..a12990e3 100644 --- a/server/AyaNova/Controllers/PickListController.cs +++ b/server/AyaNova/Controllers/PickListController.cs @@ -229,7 +229,7 @@ namespace AyaNova.Api.Controllers //type might not be supported if (PickList == null) { - return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "ayatype", $"PickList for type \"{ayaType.ToString()}\" not supported")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, null, $"PickList for type \"{ayaType.ToString()}\" not supported")); } return Ok(ApiOkResponse.Response(PickList.ColumnDefinitions)); } diff --git a/server/AyaNova/Controllers/SearchController.cs b/server/AyaNova/Controllers/SearchController.cs index 6ac5fd61..472c8cc8 100644 --- a/server/AyaNova/Controllers/SearchController.cs +++ b/server/AyaNova/Controllers/SearchController.cs @@ -120,7 +120,7 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (id == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "id", "id can't be zero")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "id can't be zero")); switch (ayaType) { @@ -136,7 +136,7 @@ namespace AyaNova.Api.Controllers AyaTypeId TypeId = await WorkOrderBiz.GetAncestor(ayaType, id, ct); return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ObjectTypeAsInt, Id = TypeId.ObjectId })); default: - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "ayaType", "Only types with ancestors are valid")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Only types with ancestors are valid")); } diff --git a/server/AyaNova/Controllers/TagController.cs b/server/AyaNova/Controllers/TagController.cs index bec7dcc3..027eba24 100644 --- a/server/AyaNova/Controllers/TagController.cs +++ b/server/AyaNova/Controllers/TagController.cs @@ -92,14 +92,14 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); if (idList.Count == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "List of ids")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids are required")); tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag required")); var JobName = $"Bulk operation: Add tag \"{tag}\" on {ayaType} ({idList.Count} specified)"; JObject o = JObject.FromObject(new @@ -134,13 +134,13 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag")); var JobName = $"Bulk operation: Add tag \"{tag}\" on any {ayaType}"; JObject o = JObject.FromObject(new @@ -175,14 +175,14 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); if (idList.Count == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "List of ids")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag")); var JobName = $"Bulk operation: Remove tag \"{tag}\" from {ayaType} ({idList.Count} specified)"; JObject o = JObject.FromObject(new @@ -218,13 +218,13 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); tag = TagBiz.NormalizeTag(tag); if (string.IsNullOrWhiteSpace(tag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "tag")); var JobName = $"Bulk operation: Remove tag \"{tag}\" from any {ayaType}"; JObject o = JObject.FromObject(new @@ -261,17 +261,17 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); if (idList.Count == 0) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "List of ids")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "List of ids")); fromTag = TagBiz.NormalizeTag(fromTag); if (string.IsNullOrWhiteSpace(fromTag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "fromTag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "fromTag")); toTag = TagBiz.NormalizeTag(toTag); if (string.IsNullOrWhiteSpace(toTag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "toTag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag")); var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {ayaType} ({idList.Count} specified)"; JObject o = JObject.FromObject(new { @@ -307,17 +307,17 @@ namespace AyaNova.Api.Controllers if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Not a taggable object type")); if (!Authorized.HasModifyRole(HttpContext.Items, ayaType)) return StatusCode(403, new ApiNotAuthorizedResponse()); fromTag = TagBiz.NormalizeTag(fromTag); if (string.IsNullOrWhiteSpace(fromTag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "fromTag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "fromTag")); toTag = TagBiz.NormalizeTag(toTag); if (string.IsNullOrWhiteSpace(toTag)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "toTag")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, null, "toTag")); var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on any {ayaType}"; JObject o = JObject.FromObject(new diff --git a/server/AyaNova/Controllers/TranslationController.cs b/server/AyaNova/Controllers/TranslationController.cs index e8a6d9eb..9d118049 100644 --- a/server/AyaNova/Controllers/TranslationController.cs +++ b/server/AyaNova/Controllers/TranslationController.cs @@ -359,7 +359,7 @@ namespace AyaNova.Api.Controllers try { if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", $"Expected a multipart request, but got {Request.ContentType}")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}")); //Save uploads to disk under temporary file names until we decide how to handle them uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext); @@ -415,7 +415,7 @@ namespace AyaNova.Api.Controllers } catch (System.IO.InvalidDataException ex) { - return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", ex.Message)); + return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message)); } finally {