Example #1
0
        //Get: AdminMainPage/ManageRolesForUser
        //it will manage the roles.
        //presenting the previous roles, user selects new roles, ALL previous roles dropped, and all user selected roles added
        public ActionResult ManageRolesForUser(string id)
        {
            if (id.IsNullOrWhiteSpace())
            {
                return(HttpNotFound("id null or whitespace"));
            }
            MyIdentityManager myIdentityManager = new MyIdentityManager();

            List <SelectListItem> passingRolesList = new List <SelectListItem>();
            var allRoles = myIdentityManager.GetAllRoles();

            if (allRoles.Count == 0)
            {
                return(HttpNotFound("No roles available in the system. Create a New Role First!"));
            }
            foreach (var role in allRoles)
            {
                SelectListItem listItem = new SelectListItem()
                {
                    Text = role.Name, Value = role.Name
                };
                passingRolesList.Add(listItem);
            }
            var dictionary = new Dictionary <string, object>();

            dictionary.Add("selectlist", passingRolesList);
            dictionary.Add("username", myIdentityManager.GetUserByIdentityUserId(id).UserName);

            IEnumerable <SelectListItem> rolesienum = myIdentityManager.AllRolesToIenumSelectListItemsForuser(id);

            dictionary.Add("ienum", rolesienum);
            myIdentityManager.Dispose();
            return(PartialView(dictionary));
        }
Example #2
0
        public async Task <ActionResult> UserEdit(string id)
        {
            if (id.IsNullOrWhiteSpace())
            {
                return(HttpNotFound("id IsNullOrWhiteSpace!"));
            }
            MyIdentityManager myIdentityManager = new MyIdentityManager();
            ApplicationUser   user;

            try {
                user = myIdentityManager.GetUserByIdentityUserId(id);
            }
            catch (Exception e) {
                return(HttpNotFound("user not found!!" + e));
            }

            MyComboItemManager          myComboItemManager = new MyComboItemManager();
            Dictionary <object, object> dictionary         = new Dictionary <object, object>();

            var I2 = myComboItemManager.GetAllRolesForUserIdToIenumSelectListItem(id);

            dictionary.Add("ienum", I2);
            dictionary.Add("applicationUser", user);

            myIdentityManager.Dispose();
            myComboItemManager.DisposeAll();
            return(PartialView("UserEdit", dictionary));
        }
Example #3
0
        public ActionResult UserDetails(string id)
        {
            if (id == null)
            {
                Debug.WriteLine("id null"); return(HttpNotFound("id null"));
            }
            MyIdentityManager           myIdentityManager      = new MyIdentityManager();
            List <object>               listOfDetailsToDisplay = new List <object>();
            Dictionary <string, object> dictionary             = new Dictionary <string, object>();

            // find what user we are talking about
            Debug.WriteLine("Details called for id: " + id);
            var user = myIdentityManager.GetUserByIdentityUserId(id);

            //ad what we need to the dictionary
            try {
                dictionary.Add("user", user);
                dictionary.Add("UserRolesList", myIdentityManager.GetUserRoles(id));
            }
            catch (Exception e) { Debug.WriteLine(e); }
            if (dictionary.Count == 0)
            {
                Debug.WriteLine("id wrong"); return(HttpNotFound("id wrong"));
            }

            //myIdentityManager.Dispose();
            return(PartialView(dictionary));
        }
Example #4
0
        public ActionResult DeleteUser(string id)
        {
            if (id.IsNullOrWhiteSpace())
            {
                return(HttpNotFound("id IsNullOrWhiteSpace!"));
            }

            MyIdentityManager myIdentityManager = new MyIdentityManager();
            var user = myIdentityManager.GetUserByIdentityUserId(id);

            myIdentityManager.Dispose();
            return(PartialView(user));
        }
Example #5
0
        public ActionResult DeleteUser(string id, FormCollection collection)
        {
            if (id.IsNullOrWhiteSpace())
            {
                return(HttpNotFound("id IsNullOrWhiteSpace!"));
            }

            MyIdentityManager myIdentityManager = new MyIdentityManager();
            var user   = myIdentityManager.GetUserByIdentityUserId(id);
            var result = myIdentityManager.DeleteMemberShipUser(user);

            myIdentityManager.Dispose();
            if (result.Succeeded)
            {
                return(Json(new { success = true }));
            }
            else
            {
                return(HttpNotFound("Error deleting user"));
            }
        }