diff --git a/.vscode/launch.json b/.vscode/launch.json index 396abc9b..bcfc56be 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -50,7 +50,7 @@ "AYANOVA_USE_URLS": "http://*:7575;", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", - "AYANOVA_SERVER_TEST_MODE":"false", + "AYANOVA_SERVER_TEST_MODE":"true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7", "AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs index 70a6090a..0063f643 100644 --- a/server/AyaNova/Controllers/NotifyController.cs +++ b/server/AyaNova/Controllers/NotifyController.cs @@ -80,6 +80,30 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(ret)); } + + /// + /// Delete app Notification + /// + /// + /// NoContent + [HttpDelete("{id}")] + public async Task DeleteAppNotification([FromRoute] long id) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + var UserId = UserIdFromContext.Id(HttpContext.Items); + var n = await ct.Notification.FirstOrDefaultAsync(z => z.Id == id); + 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")); + ct.Notification.Remove(n); + await ct.SaveChangesAsync(); + return NoContent(); + } + //------------