Esempio n. 1
0
        // GET: Users/AddUserTab
        public ActionResult AddUserTab()
        {
            if (!(GlobalVariables.GetFromCookie("NYCUser", "IsAdmin") == "True"))
            {
                return(RedirectToAction("Login", "AppUsers"));
            }
            AddUserTabs data = new AddUserTabs();

            data.lstUsers = userDAL.GetAllUsers();

            return(View(data));
        }
Esempio n. 2
0
        // GET: Users/EditUserTab
        public ActionResult EditUserTab(int ID)
        {
            if (!(GlobalVariables.GetFromCookie("NYCUser", "IsAdmin") == "True"))
            {
                return(RedirectToAction("Login", "AppUsers"));
            }
            var         record = db.User_Tabs.Find(ID);
            AddUserTabs data   = new AddUserTabs()
            {
                ID       = ID,
                Username = record.Username,
                TabIDs   = userDAL.GetTabNamesByIDs(record.TabIDs)
            };

            data.lstUsers = userDAL.GetAllUsers();

            return(View(data));
        }
Esempio n. 3
0
        public ActionResult EditUserTab(AddUserTabs data)
        {
            data.lstUsers = userDAL.GetAllUsers();
            if (ModelState.IsValid)
            {
                User_Tabs editedUser_Tab = db.User_Tabs.Find(data.ID);
                if (data.Username != editedUser_Tab.Username && db.User_Tabs.Any(w => w.Username == data.Username))
                {
                    TempData["ErrorMessage"] = "This username already exists";
                    return(View(data));
                }
                editedUser_Tab.Username        = data.Username;
                editedUser_Tab.TabIDs          = userDAL.GetTabIDsByNames(data.TabIDs);
                db.Entry(editedUser_Tab).State = EntityState.Modified;
                db.SaveChanges();
                TempData["InfoMessage"] = "User privileges has been successfully edited";
                return(RedirectToAction("UserTabs"));
            }

            return(View(data));
        }
Esempio n. 4
0
        // GET: /Users/DeleteUserTab
        public ActionResult DeleteUserTab(int ID)
        {
            if (!(GlobalVariables.GetFromCookie("NYCUser", "IsAdmin") == "True"))
            {
                return(RedirectToAction("Login", "AppUsers"));
            }
            var user_tab = db.User_Tabs.Find(ID);

            if (user_tab == null)
            {
                return(HttpNotFound());
            }
            AddUserTabs data = new AddUserTabs()
            {
                ID       = ID,
                Username = user_tab.Username,
                TabIDs   = userDAL.GetTabNamesByIDs(user_tab.TabIDs)
            };

            return(View(data));
        }
Esempio n. 5
0
        public ActionResult AddUserTab(AddUserTabs data)
        {
            data.lstUsers = userDAL.GetAllUsers();
            if (db.User_Tabs.Any(w => w.Username == data.Username))
            {
                TempData["ErrorMessage"] = "This username already exists";
                return(View(data));
            }
            if (ModelState.IsValid)
            {
                User_Tabs user_tab = new User_Tabs()
                {
                    Username = data.Username,
                    TabIDs   = userDAL.GetTabIDsByNames(data.TabIDs)
                };
                db.User_Tabs.Add(user_tab);
                db.SaveChanges();
                TempData["InfoMessage"] = "New user privileges has been successfully added";
                return(RedirectToAction("UserTabs"));
            }

            return(View(data));
        }