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));
}
}
}

View file

@ -17,18 +17,24 @@
}
<div class="row">
<div class="col-lg-12 section-heading">
<h2>Notices</h2>
<h2>@ViewData["Title"]</h2>
<hr class="primary">
</div>
</div>
<div class="row button-row">
<div class="col-lg-6">
<a asp-action="Generate" class="btn btn-primary" role="button" id="Generate"><span class="fa fa-plus"></span> Generate Test Notification</a>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<table class="table table-sm table-responsive-md">
<thead>
<tr>
<th width="160px">Date</th>
<th width="165px">Date</th>
<th>Message</th>
<th width="70px">&nbsp;</th>
<th width="70px">&nbsp;</th>
</tr>
</thead>
<tbody>
@ -46,9 +52,12 @@
{
<span>&nbsp;</span>
}
</td>
</tr>
}
</td>
<td>
<a asp-action="Delete" asp-route-id="@item.Id"><span class="fa fa-trash"></span></a>
</td>
</tr>
}
</tbody>
</table>