Making every saveChange async
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user