This commit is contained in:
2020-07-31 00:04:57 +00:00
parent 7c0f66412f
commit 7ba1f47242
7 changed files with 27 additions and 27 deletions

View File

@@ -225,7 +225,7 @@ namespace AyaNova.Api.Controllers
try try
{ {
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) 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); var uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
@@ -357,7 +357,7 @@ namespace AyaNova.Api.Controllers
} }
catch (InvalidDataException ex) 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 //Return the list of attachment ids and filenames

View File

@@ -82,7 +82,7 @@ namespace AyaNova.Api.Controllers
} }
catch (System.ArgumentOutOfRangeException e) 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? //was the name not found as a list?
if (DataList == null) 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)); return Ok(ApiOkResponse.Response(DataList.FieldDefinitions));

View File

@@ -101,7 +101,7 @@ namespace AyaNova.Api.Controllers
if (n == null) if (n == null)
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "id")); return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "id"));
if (n.UserId != UserId) 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); ct.Notification.Remove(n);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
return NoContent(); return NoContent();

View File

@@ -229,7 +229,7 @@ namespace AyaNova.Api.Controllers
//type might not be supported //type might not be supported
if (PickList == null) 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)); return Ok(ApiOkResponse.Response(PickList.ColumnDefinitions));
} }

View File

@@ -120,7 +120,7 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (id == 0) 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) switch (ayaType)
{ {
@@ -136,7 +136,7 @@ namespace AyaNova.Api.Controllers
AyaTypeId TypeId = await WorkOrderBiz.GetAncestor(ayaType, id, ct); AyaTypeId TypeId = await WorkOrderBiz.GetAncestor(ayaType, id, ct);
return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ObjectTypeAsInt, Id = TypeId.ObjectId })); return Ok(ApiOkResponse.Response(new { AyaType = TypeId.ObjectTypeAsInt, Id = TypeId.ObjectId }));
default: 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"));
} }

View File

@@ -92,14 +92,14 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0) 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); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(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)"; var JobName = $"Bulk operation: Add tag \"{tag}\" on {ayaType} ({idList.Count} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
@@ -134,13 +134,13 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
tag = TagBiz.NormalizeTag(tag); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(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}"; var JobName = $"Bulk operation: Add tag \"{tag}\" on any {ayaType}";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
@@ -175,14 +175,14 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0) 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); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(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)"; var JobName = $"Bulk operation: Remove tag \"{tag}\" from {ayaType} ({idList.Count} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
@@ -218,13 +218,13 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
tag = TagBiz.NormalizeTag(tag); tag = TagBiz.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(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}"; var JobName = $"Bulk operation: Remove tag \"{tag}\" from any {ayaType}";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
@@ -261,17 +261,17 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
if (idList.Count == 0) 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); fromTag = TagBiz.NormalizeTag(fromTag);
if (string.IsNullOrWhiteSpace(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); toTag = TagBiz.NormalizeTag(toTag);
if (string.IsNullOrWhiteSpace(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)"; var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on {ayaType} ({idList.Count} specified)";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new
{ {
@@ -307,17 +307,17 @@ namespace AyaNova.Api.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute))) 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)) if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
fromTag = TagBiz.NormalizeTag(fromTag); fromTag = TagBiz.NormalizeTag(fromTag);
if (string.IsNullOrWhiteSpace(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); toTag = TagBiz.NormalizeTag(toTag);
if (string.IsNullOrWhiteSpace(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}"; var JobName = $"Bulk operation: Replace tag \"{fromTag}\" with tag \"{toTag}\" on any {ayaType}";
JObject o = JObject.FromObject(new JObject o = JObject.FromObject(new

View File

@@ -359,7 +359,7 @@ namespace AyaNova.Api.Controllers
try try
{ {
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) 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 //Save uploads to disk under temporary file names until we decide how to handle them
uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext); uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
@@ -415,7 +415,7 @@ namespace AyaNova.Api.Controllers
} }
catch (System.IO.InvalidDataException ex) 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 finally
{ {