This commit is contained in:
2020-07-24 21:16:36 +00:00
parent ea3bc198a0
commit ea32633c60
5 changed files with 36 additions and 4 deletions

View File

@@ -139,6 +139,30 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(ret));
}
/// <summary>
/// Delete pending notification event
/// </summary>
/// <param name="id"></param>
/// <returns>NoContent</returns>
[HttpDelete("notify-event/{id}")]
public async Task<IActionResult> DeleteNotifyEvent([FromRoute] long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
if (!Authorized.HasDeleteRole(HttpContext.Items, AyaType.OpsNotificationSettings))
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
var n = await ct.NotifyEvent.FirstOrDefaultAsync(z => z.Id == id);
if (n == null)
return BadRequest(new ApiErrorResponse(ApiErrorCode.NOT_FOUND, "id"));
ct.NotifyEvent.Remove(n);
await ct.SaveChangesAsync();
return NoContent();
}
//------------