Beispiel #1
0
        public async Task <IActionResult> DesativarConta(int id)
        {
            if (!ModelState.IsValid)
            {
                TempData["Mensagem"] = ModelState;
                TempData["Alerta"]   = true;
                TempData["Classe"]   = "atencao";
                return(RedirectToAction("Index"));
            }
            else
            {
                try
                {
                    ContaService service  = new ContaService();
                    string       response = await service.Desativar(id);

                    TempData["Mensagem"] = response;
                    TempData["Alerta"]   = true;
                    TempData["Classe"]   = "sucesso";
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    TempData["Mensagem"] = ex.Message;
                    TempData["Alerta"]   = true;
                    TempData["Classe"]   = "atencao";
                    return(RedirectToAction("Index"));
                }
            }
        }