예제 #1
0
        public async Task <IActionResult> DeleteMatch(int id)
        {
            var match = await _matchService.GetByIdAsync(id);

            if (match == null)
            {
                return(NotFound());
            }

            await _matchService.DeleteAsync(match);

            return(Ok(id));
        }
        public async Task <IActionResult> Delete(MatchViewModel matchViewModel)
        {
            try
            {
                await matchService.DeleteAsync(matchViewModel.Id);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.InnerException?.Message ?? ex.Message);
                ViewData["EntityName"] = "Match";

                return(View("../Shared/_Delete", matchViewModel));
            }

            TempData["SuccessMessage"] = "Match deleted successfully.";

            return(RedirectToAction("Index"));
        }