Tweaking notification display and allowing deletion

This commit is contained in:
rockstardev
2020-05-28 22:32:31 -05:00
parent 31e0bb43e8
commit 3eb503b13b
2 changed files with 30 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ namespace BTCPayServer.Controllers
[HttpGet]
public async Task<IActionResult> Index(int skip = 0, int count = 50, int timezoneOffset = 0)
{
// TODO: Refactor
var claimWithId = User.Claims.SingleOrDefault(a => a.Type == ClaimTypes.NameIdentifier);
if (claimWithId == null)
return RedirectToAction("Index", "Home");
@@ -58,5 +59,20 @@ namespace BTCPayServer.Controllers
await Task.Delay(1000);
return RedirectToAction(nameof(Index));
}
[HttpGet]
public async Task<IActionResult> Delete(string id)
{
// TODO: Refactor
var claimWithId = User.Claims.SingleOrDefault(a => a.Type == ClaimTypes.NameIdentifier);
if (claimWithId == null)
return RedirectToAction("Index", "Home");
var notif = _db.Notifications.SingleOrDefault(a => a.Id == id && a.ApplicationUserId == claimWithId.Value);
_db.Notifications.Remove(notif);
await _db.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
}
}