Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MenuAccessLevel a = db.MenuAccessLevels.Find(id);

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.MenuAccessLevels.Remove(a);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Deleted Menu Role Assigment.";
                return(RedirectToAction("Index"));
            }
        }
Пример #2
0
        public ActionResult Create(MenuRoleVM v)
        {
            MenuAccessLevel a = new MenuAccessLevel();

            if (ModelState.IsValid)
            {
                a.MenuID = v.MenuID;
                a.RoleID = v.RoleId;

                db.MenuAccessLevels.Add(a);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Menu Role Assigment.";
                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public ActionResult Create(Menu menu)
        {
            var query = (from t in db.Menus where t.Title == menu.Title && t.IsAccountMenu == menu.IsAccountMenu select t).ToList();

            if (query.Count > 0)
            {
                ViewBag.Menu       = db.Menus.ToList();
                ViewBag.SuccessMsg = "Menu is already exist";
                return(View());
            }

            menu.MenuID        = objectSourceMaster.GetMaxNumberMenu();
            menu.IsAccountMenu = false;
            db.Menus.Add(menu);
            db.SaveChanges();
            if (menu.ParentID != null || menu.ParentID > 0)
            {
                var roles = (from d in db.RoleMasters select d).ToList();
                foreach (var item in roles)
                {
                    var menuaccess = (from d in db.MenuAccessLevels where d.ParentID == menu.ParentID && d.RoleID == item.RoleID select d).ToList();
                    if (menuaccess.Count > 0)
                    {
                        var menuaccesslevel = new MenuAccessLevel();
                        menuaccesslevel.MenuID     = menu.MenuID;
                        menuaccesslevel.RoleID     = item.RoleID;
                        menuaccesslevel.CreatedBy  = Convert.ToString(Session["UserName"]);
                        menuaccesslevel.CreatedOn  = DateTime.Now;
                        menuaccesslevel.ParentID   = menu.ParentID;
                        menuaccesslevel.IsActive   = 1;
                        menuaccesslevel.ModifiedBy = Convert.ToString(Session["UserName"]);
                        menuaccesslevel.ModifiedOn = DateTime.Now;
                        menuaccesslevel.IsView     = false;
                        menuaccesslevel.IsAdd      = false;
                        menuaccesslevel.IsDelete   = false;
                        menuaccesslevel.IsModify   = false;
                        menuaccesslevel.Isprint    = false;
                        db.MenuAccessLevels.Add(menuaccesslevel);
                        db.SaveChanges();
                    }
                }
            }
            ViewBag.SuccessMsg = "You have successfully added Menu Creation.";
            return(View("Index", db.Menus.ToList()));
        }
Пример #4
0
        public ActionResult Edit(MenuRoleVM v)
        {
            MenuAccessLevel a = new MenuAccessLevel();


            if (ModelState.IsValid)
            {
                a.MenuAccessID = v.MenuAccessID;
                a.MenuID       = v.MenuID;
                a.RoleID       = v.RoleId;

                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated Menu Role Assigment.";
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Пример #5
0
        public ActionResult Edit(int id = 0)
        {
            MenuRoleVM objViewmodel = (from t in entity.MenuAccessLevels
                                       where t.MenuAccessID == id
                                       select new MenuRoleVM

            {
                RoleId = t.RoleID,
                MenuID = t.MenuID,
                MenuAccessID = t.MenuAccessID

                               //    MenuAccessID = Convert.ToInt32(t1.Id),
            }).FirstOrDefault();


            MenuAccessLevel obj = entity.MenuAccessLevels.Find(id);

            ViewBag.Menu = new SelectList(entity.Menus.Where(d => d.IsAccountMenu == false).ToList(), "MenuID", "Title");
            ViewBag.Role = new SelectList(entity.RoleMasters, "RoleID", "RoleName");
            return(View(objViewmodel));
        }
Пример #6
0
        public ActionResult Edit(int id)
        {
            ViewBag.Menu  = db.Menus.ToList();
            ViewBag.Roles = db.RoleMasters.ToList();

            MenuAccessLevel a = db.MenuAccessLevels.Find(id);
            MenuRoleVM      v = new MenuRoleVM();

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                v.MenuAccessID = a.MenuAccessID;
                v.MenuID       = a.MenuID;
                v.RoleId       = a.RoleID;
            }

            return(View(v));
        }
Пример #7
0
        //public ActionResult Delete(int id = 0)
        //{
        //    MenuAccessLevel menuAccessLevel = entity.MenuAccessLevels.Find(id);
        //    if (menuAccessLevel == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(menuAccessLevel);

        //}
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            MenuAccessLevel menuAccessLevel = entity.MenuAccessLevels.Find(id);

            //  if (menuAccessLevel == null)
            entity.MenuAccessLevels.Remove(menuAccessLevel);
            entity.SaveChanges();
            var ChildMenus = entity.MenuAccessLevels.Where(d => d.ParentID == menuAccessLevel.MenuID && d.RoleID == menuAccessLevel.RoleID).ToList();

            foreach (var item in ChildMenus)
            {
                var secChilds = entity.MenuAccessLevels.Where(d => d.ParentID == item.MenuID && d.RoleID == menuAccessLevel.RoleID).ToList();
                foreach (var data in secChilds)
                {
                    entity.MenuAccessLevels.Remove(data);
                    entity.SaveChanges();
                }
                entity.MenuAccessLevels.Remove(item);
                entity.SaveChanges();
            }
            ViewBag.SuccessMsg = "You have successfully added Menu Role List.";
            return(RedirectToAction("List"));
        }
Пример #8
0
        public ActionResult Index(MenuRoleVM model)
        {
            MenuAccessLevel obj = new MenuAccessLevel();

            obj.RoleID     = model.RoleId;
            obj.MenuID     = model.MenuID;
            obj.CreatedOn  = DateTime.Now;
            obj.CreatedBy  = Convert.ToString(Session["UserName"]);
            obj.ParentID   = model.ParentID;
            obj.IsActive   = 1;
            obj.ModifiedBy = Convert.ToString(Session["UserName"]);
            obj.ModifiedOn = DateTime.Now;
            obj.IsView     = true;
            obj.IsAdd      = true;
            obj.IsDelete   = true;
            obj.IsModify   = true;
            obj.Isprint    = true;

            entity.MenuAccessLevels.Add(obj);
            entity.SaveChanges();

            var ChildMenus = entity.Menus.Where(d => d.ParentID == model.MenuID && d.IsAccountMenu == false).ToList();

            foreach (var item in ChildMenus)
            {
                var data = entity.MenuAccessLevels.Where(d => d.MenuID == item.MenuID && d.RoleID == model.RoleId).FirstOrDefault();
                if (data == null)
                {
                    data            = new MenuAccessLevel();
                    data.MenuID     = item.MenuID;
                    data.ParentID   = item.ParentID;
                    data.RoleID     = model.RoleId;
                    data.CreatedOn  = DateTime.Now;
                    data.CreatedBy  = Convert.ToString(Session["UserName"]);
                    data.IsActive   = 1;
                    data.ModifiedBy = Convert.ToString(Session["UserName"]);
                    data.ModifiedOn = DateTime.Now;
                    data.IsView     = true;
                    data.IsAdd      = true;
                    data.IsDelete   = true;
                    data.IsModify   = true;
                    data.Isprint    = true;
                    entity.MenuAccessLevels.Add(data);
                    entity.SaveChanges();


                    var secondchilds = entity.Menus.Where(d => d.ParentID == item.MenuID && d.IsAccountMenu == false).ToList();

                    foreach (var childs in secondchilds)
                    {
                        var data1 = entity.MenuAccessLevels.Where(d => d.MenuID == childs.MenuID && d.RoleID == model.RoleId).FirstOrDefault();
                        if (data1 == null)
                        {
                            data1            = new MenuAccessLevel();
                            data1.MenuID     = childs.MenuID;
                            data1.ParentID   = childs.ParentID;
                            data1.RoleID     = model.RoleId;
                            data1.CreatedOn  = DateTime.Now;
                            data1.CreatedBy  = Convert.ToString(Session["UserName"]);
                            data1.IsActive   = 1;
                            data1.ModifiedBy = Convert.ToString(Session["UserName"]);
                            data1.ModifiedOn = DateTime.Now;
                            data1.IsView     = true;
                            data1.IsAdd      = true;
                            data1.IsDelete   = true;
                            data1.IsModify   = true;
                            data1.Isprint    = true;
                            entity.MenuAccessLevels.Add(data1);
                            entity.SaveChanges();
                        }
                    }
                }
            }
            ViewBag.SuccessMsg = "You have successfully added Menu Role List.";
            return(RedirectToAction("List"));
        }
 public virtual MenuAccessLevel Put(MenuAccessLevel menuAccessLevel)
 {
     _menuAccessLevelCommands.ActiveUser = Models.ApiContext.ActiveUser;
     return(_menuAccessLevelCommands.Put(menuAccessLevel));
 }