public ActionResult DeleteConfirmed(int id) { try { LogBLL.Insert(new LogDado("DeleteConfirmed(int id)", "Ação", _idUsuario)); using (Context db = new Context()) { using (var trans = new RP.DataAccess.RPTransactionScope(db)) { BLL.AcaoBLL acaoBLL = new BLL.AcaoBLL(db, _idUsuario); acaoBLL.Delete(e => e.idAcao == id); acaoBLL.SaveChanges(); trans.Complete(); this.AddFlashMessage(RP.Util.Resource.Message.DELETE_SUCCESS, FlashMessage.SUCCESS); return RedirectToAction("Index"); } } } catch (Exception ex) { RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario); return RedirectToAction("Delete", id); } }
public ActionResult Edit(AcaoVM viewData) { try { if (ModelState.IsValid) { Acao acao = viewData.VM2E(); LogBLL.Insert(new LogDado("Edit(AcaoVM viewData)", "Ação", _idUsuario)); using (Context db = new Context()) { using (var trans = new RP.DataAccess.RPTransactionScope(db)) { acao.flMenu = acao.flMenu.ToLower() == "true" || acao.flMenu.ToLower() == "sim" ? "Sim" : "Não"; BLL.AcaoBLL acaoBLL = new BLL.AcaoBLL(db, _idUsuario); acaoBLL.Update(acao); acaoBLL.SaveChanges(); trans.Complete(); this.AddFlashMessage(RP.Util.Resource.Message.EDIT_SUCCESS, FlashMessage.SUCCESS); return RedirectToAction("Index"); } } } return View(viewData); } catch (Exception ex) { RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario); return RedirectToAction("Index"); } }