This commit is contained in:
2020-07-20 17:36:59 +00:00
parent 723fdf872f
commit 0842ce025e

View File

@@ -65,6 +65,20 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
}
/// <summary>
/// Get all in-app notifications
/// </summary>
/// <returns></returns>
[HttpGet("app-notifications")]
public async Task<IActionResult> 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));
}
//------------