Beispiel #1
0
        public async Task <IActionResult> DeleteConfirmed(int?id, [FromServices] IInstructorService service)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            try
            {
                await service.DeleteInstructorAndSaveAsync(id.Value);

                TempData["Message"] = Constants.SUCCESS_MESSAGE;
                return(RedirectToAction(nameof(Index)));
            }
            catch (GeneralException ex)
            {
                TempData["Message"]  = ex.Message;
                TempData["HasError"] = true;
                return(RedirectToAction(nameof(Delete), new { id = id.Value }));
            }
            catch (Exception ex)
            {
                TempData["Message"]  = Constants.ERROR_MESSAGE_STANDARD + ": " + ex.Message;
                TempData["HasError"] = true;
                return(RedirectToAction(nameof(Delete), new { id = id.Value }));
            }
        }