This commit is contained in:
@@ -71,7 +71,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||
return Ok(ApiOkResponse.Response(await ct.Notification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
|
||||
return Ok(ApiOkResponse.Response(await ct.InAppNotification.CountAsync(z => z.UserId == UserId && z.Fetched == false)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,8 +84,8 @@ namespace AyaNova.Api.Controllers
|
||||
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}");
|
||||
var ret = await ct.InAppNotification.AsNoTracking().Where(z => z.UserId == UserId).OrderByDescending(z => z.Created).ToListAsync();
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"update ainappnotification set fetched={true} where userid = {UserId}");
|
||||
return Ok(ApiOkResponse.Response(ret));
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ namespace AyaNova.Api.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||
var n = await ct.Notification.FirstOrDefaultAsync(z => z.Id == id);
|
||||
var n = await ct.InAppNotification.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, null, "Can't delete notification for another user"));
|
||||
ct.Notification.Remove(n);
|
||||
ct.InAppNotification.Remove(n);
|
||||
await ct.SaveChangesAsync();
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user