Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {            
            try
            {
                using (Context db = new Context())
                {
                    using (var trans = new RP.DataAccess.RPTransactionScope(db))
                    {
	                    BLL.ModuloBLL moduloBLL = new BLL.ModuloBLL(db, _idUsuario);
                        moduloBLL.Delete(e => e.idModulo == id);
                        moduloBLL.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);
                this.AddFlashMessage(RP.Util.Exception.Message.Get(ex), FlashMessage.ERROR); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                return RedirectToAction("Delete", id);
            }
        }
Ejemplo n.º 2
0
        public ActionResult AddUsuario(int id, Models.Modulo.AdminVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Modulo.idModulo = id;
                    var modulo = model.VM2E();

                    using (Context db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
                            BLL.ModuloBLL moduloBLL = new BLL.ModuloBLL(db, _idUsuario);
                            moduloBLL.UpdateUsuarios(modulo);
                            moduloBLL.SaveChanges();
                            trans.Complete();

                            this.AddFlashMessage(RP.Util.Resource.Message.EDIT_SUCCESS, FlashMessage.SUCCESS);
                            return RedirectToAction("Index");
                        }
                    }
                }
                return View(model);
            }
            catch (RP.Sistema.BLL.RPSistemaException exRP)
            {
                this.AddFlashMessage(exRP.Message, FlashMessage.ALERT);
                return View(model);
            }
            catch (Exception ex)
            {
                this.AddFlashMessage(RP.Util.Exception.Message.Get(ex), FlashMessage.ERROR); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                return RedirectToAction("Index");
            }      
        }
Ejemplo n.º 3
0
        public ActionResult Edit(RP.Sistema.Web.Models.Modulo.ModuloVM viewData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var modulo = viewData.VM2E();
                    using (Context db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
		                    BLL.ModuloBLL moduloBLL = new BLL.ModuloBLL(db, _idUsuario);
                            moduloBLL.Update(modulo);
                            moduloBLL.SaveChanges();
                            trans.Complete();

                            this.AddFlashMessage(RP.Util.Resource.Message.EDIT_SUCCESS, FlashMessage.SUCCESS);
                            return RedirectToAction("Index");
                        }
                    }
                }
                return View(viewData);
            }
            catch (Exception ex) 
            {
                this.AddFlashMessage(RP.Util.Exception.Message.Get(ex), FlashMessage.ERROR); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                return RedirectToAction("Index");
            }        
		}