Making every saveChange async

This commit is contained in:
Benjamin
2025-01-08 17:34:39 +01:00
parent 9368810703
commit 14280f7f97
3 changed files with 10 additions and 10 deletions

View File

@@ -49,14 +49,14 @@ namespace pointMaster.Controllers
}
[HttpPost]
public IActionResult Create(Patrulje patrulje)
public async Task<IActionResult> Create(Patrulje patrulje)
{
patrulje.DateCreated = DateTime.UtcNow;
_context.Patruljer.Add(patrulje);
_context.SaveChanges();
await _context.Patruljer.AddAsync(patrulje);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
return RedirectToAction(nameof(Index));
}
public async Task<IActionResult> AddMedlem(int? id)
@@ -106,7 +106,7 @@ namespace pointMaster.Controllers
if (medlem != null)
{
_context.PatruljeMedlemmer.Remove(medlem);
_context.SaveChanges();
await _context.SaveChangesAsync();
}
return RedirectToAction(nameof(Index));
@@ -121,7 +121,7 @@ namespace pointMaster.Controllers
if (patrulje != null)
{
_context.Patruljer.Remove(patrulje);
_context.SaveChanges();
await _context.SaveChangesAsync();
}
return RedirectToAction(nameof(Index));

View File

@@ -175,13 +175,13 @@ namespace pointMaster.Controllers
}
[Authorize(Policy = Roles.Editor)]
public ActionResult DeletePoint(int id)
public async Task<ActionResult> DeletePoint(int id)
{
var point = context.Points.FirstOrDefault(p => p.Id == id);
if (point == null) { return NotFound(); }
context.Points.Remove(point);
context.SaveChanges();
await context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}

View File

@@ -47,7 +47,7 @@ namespace pointMaster.Controllers
}
[HttpGet]
public ActionResult SletPost(int id)
public async Task<ActionResult> SletPost(int id)
{
var post = _context.Poster.Find(id);
@@ -57,7 +57,7 @@ namespace pointMaster.Controllers
}
_context.Poster.Remove(post);
_context.SaveChanges();
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}