got Abstraction

This commit is contained in:
Paul Schneider
2023-03-19 16:02:50 +00:00
parent ca9af3f5a0
commit 6fe0dad775
11 changed files with 118 additions and 80 deletions

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Extensions.Localization;
using Microsoft.AspNet.Authorization;
using System.Linq;
namespace Yavsc.Controllers
{
@ -148,5 +149,36 @@ namespace Yavsc.Controllers
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
[Authorize("AdministratorOnly")]
public async Task<IActionResult> DeleteAllLike(long? id)
{
if (id == null)
{
return HttpNotFound();
}
Bug bugref = await _context.Bug.SingleAsync(m => m.Id == id);
if (bugref == null)
{
return null;
}
var bugs = _context.Bug.Where(b => b.Description == bugref.Description);
return View(bugs);
}
// POST: Bug/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
[Authorize("AdministratorOnly")]
public async Task<IActionResult> DeleteAllLikeConfirmed(long id)
{
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
var bugs = await _context.Bug.Where(b => b.Description == bug.Description).ToArrayAsync();
foreach (var btd in bugs)
_context.Bug.Remove(btd);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
}