Esempio n. 1
0
        public ActionResult EditSubMenus(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            sidebar_menus sidebarMenus = db.sidebar_menus.Find(id);

            return(View(sidebarMenus));
        }
Esempio n. 2
0
        public string Delete(int id)
        {
            string        message       = "Success";
            sidebar_menus sidebar_Menus = db.sidebar_menus.Find(id);

            sidebar_Menus.IsDeleted  = 1;
            sidebar_Menus.ModifiedOn = DateTime.Now;
            db.SaveChanges();

            return(message);
        }
Esempio n. 3
0
        public ActionResult CreateSubMenus(sidebar_menus sidebarMenu)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            int menuId = Convert.ToInt32(sidebarMenu.MenuId);

            string menuName = db.menus.Where(m => m.Id == menuId).Select(m => m.MenuName).FirstOrDefault();

            if (menuName == "Auto Report/Escalation")
            {
                string[] splitString = menuName.Split('/');
                string   name        = splitString[0] + "/" + "<br/>" + splitString[1];
                menuName = name;
            }

            var sidebarMenuList = db.sidebar_menus.Where(m => m.MenuName == menuName).ToList();
            var subMenu         = db.sidebar_menus.Where(m => m.MenuName == menuName).Select(m => m.SubMenuName).FirstOrDefault();

            if (sidebarMenuList.Count == 1 && subMenu == null)
            {
                foreach (var item in sidebarMenuList)
                {
                    item.SubMenuName = sidebarMenu.SubMenuName;
                    item.SubMenuURL  = sidebarMenu.SubMenuURL;
                    db.SaveChanges();

                    break;
                }
            }
            else
            {
                sidebar_menus sidebar_Menus = new sidebar_menus();
                sidebar_Menus.SubMenuName = sidebarMenu.SubMenuName;
                sidebar_Menus.MenuName    = menuName;
                sidebar_Menus.SubMenuURL  = sidebarMenu.SubMenuURL;
                sidebar_Menus.IsDeleted   = 0;
                sidebar_Menus.MenuId      = menuId;
                db.sidebar_menus.Add(sidebar_Menus);
                db.SaveChanges();
            }
            TempData["toaster_success"] = "SubMenu Added Successfully";

            ViewData["Menus"] = new SelectList(db.menus.Where(m => m.IsDeleted == 0), "id", "MenuName").ToList();
            return(View("SubMenusList"));
        }
Esempio n. 4
0
        public ActionResult EditSubMenus(sidebar_menus sidebarMenu)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            sidebar_menus sidebar_Menus = db.sidebar_menus.Find(sidebarMenu.id);

            sidebar_Menus.SubMenuName = sidebarMenu.SubMenuName;
            sidebar_Menus.SubMenuURL  = sidebarMenu.SubMenuURL;
            db.SaveChanges();

            TempData["toaster_success"] = "SubMenu Updated Successfully";

            ViewData["Menus"] = new SelectList(db.menus.Where(m => m.IsDeleted == 0), "id", "MenuName").ToList();
            return(View("SubMenusList"));
        }
Esempio n. 5
0
        public ActionResult EditMenus(sidebar_menus menus, HttpPostedFileBase imageFile, string MenuStyle, int DashboardAccess = 0, int SidebarAccess = 0, string getImage = null)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            if (DashboardAccess == 2)
            {
                DashboardAccess = 0;
            }
            if (SidebarAccess == 2)
            {
                SidebarAccess = 0;
            }

            if (imageFile != null)
            {
                getImage = null;
            }

            string imageUrl = "", imageUrl1 = "";

            if (imageFile != null && getImage == null)
            {
                int imageSize = imageFile.ContentLength;
                if ((imageSize / 1024 / 1024) < 1)
                {
                    string   fileExtension = Path.GetExtension(imageFile.FileName);
                    string   imgName       = imageFile.FileName;
                    string[] imgSplit      = imgName.Split('.');
                    Image    img           = Image.FromStream(imageFile.InputStream, true, true);
                    if (DashboardAccess == 1)
                    {
                        Image  imgSave = ReduceImageSize(img, "DashImage", null);
                        string imgUrl  = SaveImage(imgSave, imageFile.FileName, "DashImage", null);
                        imageUrl = "/images/" + imageFile.FileName;
                    }
                    if (SidebarAccess == 1)
                    {
                        Image  imgSave1 = ReduceImageSize(img, null, "SideImage");
                        string imgUrl1  = SaveImage(imgSave1, imgSplit[0], null, "SideImage", fileExtension);
                        imageUrl1 = "/images/" + imgSplit[0] + "(1)" + fileExtension;
                    }
                }
                else
                {
                    int    id      = Convert.ToInt32(menus.id);
                    string Message = "Image Size is larger";
                    return(RedirectToAction("EditMenus", new { id, Message }));
                }
            }

            menu menu = db.menus.Find(menus.id);

            menu.MenuName = menus.MenuName;
            var value        = menu.DisplayOrder;
            int displayOrder = Convert.ToInt32(value);

            if (displayOrder != menus.DisplayOrder)
            {
                if (displayOrder < menus.DisplayOrder)
                {
                    var menuList = db.menus.Where(m => m.DisplayOrder > displayOrder && m.DisplayOrder <= menus.DisplayOrder).ToList();
                    foreach (var item in menuList)
                    {
                        item.DisplayOrder = item.DisplayOrder - 1;
                        db.SaveChanges();
                    }
                }
                else if (displayOrder > menus.DisplayOrder)
                {
                    var menuList = db.menus.Where(m => m.DisplayOrder >= menus.DisplayOrder && m.DisplayOrder <= displayOrder).ToList();
                    foreach (var item in menuList)
                    {
                        item.DisplayOrder = item.DisplayOrder + 1;
                        db.SaveChanges();
                    }
                }
                menu.DisplayOrder = menus.DisplayOrder;
            }
            menu.IsDashboard   = DashboardAccess;
            menu.IsSideMenubar = SidebarAccess;
            db.SaveChanges();

            var menuId = db.menus.Where(m => m.MenuName == menus.MenuName).Select(m => m.Id).FirstOrDefault();

            if (SidebarAccess == 1)
            {
                sidebar_menus sidebarMenus = db.sidebar_menus.Where(m => m.IsDeleted == 0 && m.MenuId == menus.id).FirstOrDefault();
                sidebarMenus.MenuName = menus.MenuName;
                sidebarMenus.MenuId   = menuId;
                if (menus.MenuURL != null)
                {
                    sidebarMenus.MenuURL = menus.MenuURL;
                }
                if (imageFile != null && getImage == null && imageUrl1 != "")
                {
                    sidebarMenus.ImageURL = imageUrl1;
                }
                db.SaveChanges();
            }

            if (DashboardAccess == 1)
            {
                var dashboardMenu = db.dashboard_menus.Where(m => m.IsDeleted == 0 && m.MenuId == menuId).FirstOrDefault();
                dashboardMenu.MenuName = menus.MenuName;
                dashboardMenu.MenuId   = menuId;
                if (menus.MenuURL != null)
                {
                    dashboardMenu.MenuUrl = menus.MenuURL;
                }
                if (imageFile != null && getImage == null && imageUrl != "")
                {
                    dashboardMenu.ImageUrl = imageUrl;
                }
                if (MenuStyle != "")
                {
                    dashboardMenu.ColourDiv = MenuStyle;
                }
                db.SaveChanges();
            }

            TempData["toaster_success"] = "Menu Updated Successfully";
            return(RedirectToAction("MenusList"));
        }
Esempio n. 6
0
        public ActionResult CreateMenus(sidebar_menus menus, HttpPostedFileBase imageFile, string MenuStyle, int DashboardAccess = 0, int SidebarAccess = 0, int roleid = 0)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }

            string imageUrl = "", imageUrl1 = "";

            if (imageFile != null)
            {
                int imageSize = imageFile.ContentLength;
                if ((imageSize / 1024 / 1024) < 1)
                {
                    string   fileExtension = Path.GetExtension(imageFile.FileName);
                    string   imgName       = imageFile.FileName;
                    string[] imgSplit      = imgName.Split('.');
                    Image    img           = Image.FromStream(imageFile.InputStream, true, true);
                    if (DashboardAccess == 1)
                    {
                        Image  imgSave = ReduceImageSize(img, "DashImage", null);
                        string imgUrl  = SaveImage(imgSave, imageFile.FileName, "DashImage", null);
                        imageUrl = "/images/" + imageFile.FileName;
                    }
                    if (SidebarAccess == 1)
                    {
                        Image  imgSave1 = ReduceImageSize(img, null, "SideImage");
                        string imgUrl1  = SaveImage(imgSave1, imgSplit[0], null, "SideImage", fileExtension);
                        imageUrl1 = "/images/" + imgSplit[0] + "(1)" + fileExtension;
                    }
                }
                else
                {
                    ViewBag.DisplayOrder        = new SelectList(db.menus.Where(m => m.IsDeleted == 0).OrderBy(m => m.DisplayOrder), "DisplayOrder", "DisplayOrder");
                    ViewData["MenuStyle"]       = new SelectList(db.dashboard_menus.Where(m => m.IsDeleted == 0 && m.ColourDiv != null), "Id", "ColourDiv", MenuStyle).ToList();
                    TempData["toaster_warning"] = "Image Size is larger";
                    return(View());
                }
            }

            var value = db.menus.Where(m => m.DisplayOrder == menus.DisplayOrder).Select(m => m.DisplayOrder).FirstOrDefault();

            if (value != null)
            {
                int displayOrder = Convert.ToInt32(value);

                var menuList = db.menus.Where(m => m.IsDeleted == 0 && m.DisplayOrder >= displayOrder).ToList();
                foreach (var item in menuList)
                {
                    item.DisplayOrder = item.DisplayOrder + 1;
                    db.SaveChanges();
                }
            }
            menu menu = new menu();

            menu.MenuName      = menus.MenuName;
            menu.IsDeleted     = 0;
            menu.IsDashboard   = DashboardAccess;
            menu.IsSideMenubar = SidebarAccess;
            menu.DisplayOrder  = menus.DisplayOrder;
            db.menus.Add(menu);
            db.SaveChanges();

            var menuId = db.menus.Where(m => m.MenuName == menus.MenuName).Select(m => m.Id).FirstOrDefault();

            if (SidebarAccess == 1)
            {
                sidebar_menus sidebarMenus = new sidebar_menus();
                sidebarMenus.MenuName = menus.MenuName;
                sidebarMenus.MenuId   = menuId;
                sidebarMenus.MenuURL  = menus.MenuURL;
                if (imageUrl1 != "")
                {
                    sidebarMenus.ImageURL = imageUrl1;
                }
                sidebarMenus.IsDeleted = 0;
                db.sidebar_menus.Add(sidebarMenus);
                db.SaveChanges();
            }



            if (DashboardAccess == 1)
            {
                dashboard_menus dashboardMenus = new dashboard_menus();
                dashboardMenus.MenuName  = menus.MenuName;
                dashboardMenus.MenuUrl   = menus.MenuURL;
                dashboardMenus.MenuId    = menuId;
                dashboardMenus.ColourDiv = MenuStyle;
                if (imageUrl != "")
                {
                    dashboardMenus.ImageUrl = imageUrl;
                }
                dashboardMenus.IsDeleted = 0;
                db.dashboard_menus.Add(dashboardMenus);
                db.SaveChanges();
            }


            //date: 25-8-2020 (issue in side bar menu not displaying newly created menu item)
            int        roleId  = Convert.ToInt32(Session["RoleID"]);
            user_menus userval = new user_menus();

            userval.MenuId     = menuId;
            userval.RoleId     = roleid;
            userval.MenuStatus = true;
            userval.IsDeleted  = 0;
            db.user_menus.Add(userval);
            db.SaveChanges();


            TempData["toaster_success"] = "Menu Added Successfully";
            return(RedirectToAction("MenusList"));
        }