public IActionResult DeleteGame([FromRoute] string id) { var game = adminServices.GetGamebyId(id).Single(); var gameVM = new AdminDeleteGameViewModel { Id = game.Id }; return(View(gameVM)); }
public IActionResult DeleteGame([FromForm] AdminDeleteGameViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } var userId = userManager.GetUserId(User); adminServices.deleteGame(userId, model.Id); return(Redirect(Url.Action("Index", "Admin"))); // return Redirect(Url.Action("AddGame", "Admin")); }
// POST public IHttpResponse Delete(AdminDeleteGameViewModel model) { var redirectResponse = this.RedirectIfNotAdminOrNotAthenticated(); if (redirectResponse != null) { return(redirectResponse); } bool isDeleted = this.gameService.Delete(model.GameId); if (!isDeleted) { this.ShowError("Game not found!"); return(this.Delete(model.GameId)); } return(this.RedirectResponse(Routes.ListAllGamesPath)); }