Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                try
                {
                    rs_action rs_action = db.rs_action.Single(s => s.ActionId == id);

                    Logger.Log("Delete", "Delete Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");
                    TempData["Notification"] = NotificationHelper.Inform("Delete Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");

                    db.rs_action.Remove(rs_action);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    TempData["Notification"] = NotificationHelper.Error(ex.Message);
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
Пример #2
0
        //
        // GET: /Action/Delete/5

        public ActionResult Delete(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_action rs_action = db.rs_action.Single(s => s.ActionId == id);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
Пример #3
0
        //
        // GET: /Action/Edit/5

        public ActionResult Edit(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_action rs_action = db.rs_action.Single(s => s.ActionId == id);
                ViewBag.ModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name", rs_action.ModuleId);
                //ViewBag.UserEntry = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserEntry);
                //ViewBag.UserUpdate = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserUpdate);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
Пример #4
0
        public ActionResult Edit(rs_action rs_action)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_action current = db.rs_action.SingleOrDefault(m => m.ModuleId == rs_action.ModuleId &&
                                                                     m.Name.ToLower() == rs_action.Name.ToLower() &&
                                                                     m.ActionId != rs_action.ActionId
                                                                     );
                    if (current != null)
                    {
                        TempData["Notification"] = NotificationHelper.Error("Action already exist.");
                    }
                    else
                    {
                        try
                        {
                            rs_action.UserUpdate = User.Identity.Name;
                            rs_action.DateUpdate = DateTime.Now;

                            db.rs_action.Attach(rs_action);
                            db.Entry(rs_action).State = EntityState.Modified;
                            //db.ObjectStateManager.ChangeObjectState(rs_action, EntityState.Modified);
                            db.SaveChanges();

                            Logger.Log("Edit", "Edit Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");

                            TempData["Notification"] = NotificationHelper.Inform("Edit Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");
                            return(RedirectToAction("Index"));
                        }
                        catch (Exception ex)
                        {
                            TempData["Notification"] = NotificationHelper.Error(ex.Message);
                        }
                    }
                }

                ViewBag.ModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name", rs_action.ModuleId);
                //ViewBag.UserEntry = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserEntry);
                //ViewBag.UserUpdate = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserUpdate);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }