public ActionResult ConfirmarExcluir(long id) { var usuario = _servicoUsuario.ObterPeloId(id); if (usuario == null) { return HttpNotFound(); } if (usuario.EhAdministrador) { throw new Exception(Exceptions.ActionNotAllowed); } try { _servicoUsuario.Excluir(usuario); Success(Alerts.Success, true); return RedirectToAction("Index"); } catch (Exception exception) { Erro(Alerts.Erro, true, exception); } var modelo = new UsuarioEditModel { Id = usuario.Id, Nome = usuario.Nome, Sobrenome = usuario.Sobrenome, Email = usuario.Email, }; return View(modelo); }
public ActionResult Excluir(long? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var usuario = _servicoUsuario.ObterPeloId(id.Value); if (usuario == null) { return HttpNotFound(); } if (usuario.EhAdministrador) { return RedirectToAction("Index"); } var modelo = new UsuarioEditModel { Id = usuario.Id, Nome = usuario.Nome, Sobrenome = usuario.Sobrenome, Email = usuario.Email, }; return View(modelo); }
public ActionResult Detalhar(long? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var usuario = _servicoUsuario.ObterPeloId(id.Value); if (usuario == null) { return HttpNotFound(); } var model = new UsuarioEditModel { Id = usuario.Id, Nome = usuario.Nome, Sobrenome = usuario.Sobrenome, Email = usuario.Email, }; return View(model); }