This commit is contained in:
@@ -65,6 +65,20 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user