From 0842ce025ea5f9a24070c10cda24a6bb59272d6b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 Jul 2020 17:36:59 +0000 Subject: [PATCH] --- server/AyaNova/Controllers/NotifyController.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/AyaNova/Controllers/NotifyController.cs b/server/AyaNova/Controllers/NotifyController.cs index c7280434..70a6090a 100644 --- a/server/AyaNova/Controllers/NotifyController.cs +++ b/server/AyaNova/Controllers/NotifyController.cs @@ -65,6 +65,20 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false))); } + /// + /// Get all in-app notifications + /// + /// + [HttpGet("app-notifications")] + public async Task GetAppNotifications() + { + if (serverState.IsClosed) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + var UserId = UserIdFromContext.Id(HttpContext.Items); + var ret = await ct.Notification.AsNoTracking().Where(z => z.UserId == UserId).OrderByDescending(z => z.Created).ToListAsync(); + await ct.Database.ExecuteSqlInterpolatedAsync($"update anotification set fetched={true} where userid = {UserId}"); + return Ok(ApiOkResponse.Response(ret)); + } //------------