Bug managment : deletions

This commit is contained in:
Paul Schneider
2024-12-25 14:55:57 +00:00
parent c7ca9b0801
commit ecee97085d
4 changed files with 20 additions and 11 deletions

View File

@ -27,9 +27,12 @@ namespace Yavsc.Controllers
}
// GET: Bug
public async Task<IActionResult> Index()
public async Task<IActionResult> Index(int skip = 0, int take = 25)
{
return View(await _context.Bug.ToListAsync());
if (take > 50) return BadRequest();
ViewData["skip"]=skip;
ViewData["take"]=take;
return View(await _context.Bug.Skip(skip).Take(take).ToListAsync());
}
// GET: Bug/Details/5
@ -135,6 +138,8 @@ namespace Yavsc.Controllers
return View(bug);
}
// POST: Bug/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
@ -168,10 +173,10 @@ namespace Yavsc.Controllers
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize("AdministratorOnly")]
public async Task<IActionResult> DeleteAllLikeConfirmed(long id)
public async Task<IActionResult> DeleteAllLikeConfirmed(long id, int prefixLen = 25)
{
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
var bugs = await _context.Bug.Where(b => b.Description == bug.Description).ToArrayAsync();
var bugs = await _context.Bug.Where(b => b.Description.Substring(0, prefixLen) == bug.Description.Substring(0, prefixLen)).ToArrayAsync();
foreach (var btd in bugs)
_context.Bug.Remove(btd);
await _context.SaveChangesAsync();

View File

@ -45,7 +45,9 @@
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="DeleteAllLike" asp-route-id="@item.Id">Delete</a>
<form asp-action="DeleteAllLikeConfirmed" asp-route-id="@item.Id" method="POST">
<input class="btm btm-primary" type="submit" value="Delete"></input>
</form>
</td>
</tr>
}

View File

@ -11,22 +11,22 @@
<hr />
<dl class="dl-horizontal">
<dt>
FeatureId"]
Feature Id
</dt>
<dd>
@Html.DisplayFor(model => model.FeatureId)
</dd>
<dt>
Title"]
Title
</dt>
<dd>
@Html.DisplayFor(model => model.Title)
</dd>
<dt>
Status"]
Status
</dt>
<dd>
@typeof(Yavsc.Models.IT.Fixing.BugStatus).GetEnumNames()[(int)Model.Status]
@Html.DisplayFor(model => model.Status)
</dd>
</dl>
@ -35,6 +35,7 @@
</div>
<p>
[<a asp-action="DeleteAllLike" asp-route-id="@Model.Id">Delete all like this one</a> |
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
<a asp-action="Index">Back to List</a>]
</p>

View File

@ -146,7 +146,8 @@ $.widget("psc.blogcomment", {
});
$(document).ready(function() {
jQuery(function() {
$("[data-type='blogcomment']").blogcomment();
})