Making every saveChange async
This commit is contained in:
@@ -49,14 +49,14 @@ namespace pointMaster.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult Create(Patrulje patrulje)
|
public async Task<IActionResult> Create(Patrulje patrulje)
|
||||||
{
|
{
|
||||||
patrulje.DateCreated = DateTime.UtcNow;
|
patrulje.DateCreated = DateTime.UtcNow;
|
||||||
|
|
||||||
_context.Patruljer.Add(patrulje);
|
await _context.Patruljer.AddAsync(patrulje);
|
||||||
_context.SaveChanges();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction(nameof(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> AddMedlem(int? id)
|
public async Task<IActionResult> AddMedlem(int? id)
|
||||||
@@ -106,7 +106,7 @@ namespace pointMaster.Controllers
|
|||||||
if (medlem != null)
|
if (medlem != null)
|
||||||
{
|
{
|
||||||
_context.PatruljeMedlemmer.Remove(medlem);
|
_context.PatruljeMedlemmer.Remove(medlem);
|
||||||
_context.SaveChanges();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
@@ -121,7 +121,7 @@ namespace pointMaster.Controllers
|
|||||||
if (patrulje != null)
|
if (patrulje != null)
|
||||||
{
|
{
|
||||||
_context.Patruljer.Remove(patrulje);
|
_context.Patruljer.Remove(patrulje);
|
||||||
_context.SaveChanges();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
|
|||||||
@@ -175,13 +175,13 @@ namespace pointMaster.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Roles.Editor)]
|
[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);
|
var point = context.Points.FirstOrDefault(p => p.Id == id);
|
||||||
if (point == null) { return NotFound(); }
|
if (point == null) { return NotFound(); }
|
||||||
|
|
||||||
context.Points.Remove(point);
|
context.Points.Remove(point);
|
||||||
context.SaveChanges();
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace pointMaster.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ActionResult SletPost(int id)
|
public async Task<ActionResult> SletPost(int id)
|
||||||
{
|
{
|
||||||
var post = _context.Poster.Find(id);
|
var post = _context.Poster.Find(id);
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ namespace pointMaster.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
_context.Poster.Remove(post);
|
_context.Poster.Remove(post);
|
||||||
_context.SaveChanges();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return RedirectToAction(nameof(Index));
|
return RedirectToAction(nameof(Index));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user