示例#1
0
        public ActionResult Delete(string id)
        {
            UserAccessRepository rep = new UserAccessRepository();
            Guid ID = Guid.Parse(id);

            try
            {
                if (rep.NumberOfUsersInRole(ID) == 0)
                {
                    if (rep.DeleteRole(ID))
                    {
                        ViewData["Message"] = "Role deleted successfully!";
                    }
                    else
                    {
                        ViewData["Message"] = "There was an error deleting role. Please contact your administrator.";
                    }
                }
                else
                {
                    ViewData["Message"] = "Role couldn't be deleted because there are users under this role.";
                }
            }
            catch
            {
                return(View());
            }

            return(View());
        }