Пример #1
0
        public ActionResult Delete(int UserId = 0)
        {
            var user = BugReporter_v2.DAL.UserDAL.FindUser(UserId);
            RouteValueDictionary routeValues;
            bool isAdmin = Roles.IsUserInRole(user.UserName, "Administrator");

            if (user == null || isAdmin)
            {
                routeValues = this.GridRouteValues();

                return(RedirectToAction("Index", routeValues));
            }
            var    deletedUser = UserDAL.GetUserById(UserId);
            string name        = deletedUser.UserName;

            BugDAL.DeleteBugsToUser(UserId);
            LogDAL.DeleteLogsForUser(UserId);
            Roles.RemoveUserFromRole(name, "User");
            ProjectDAL.DeleteAllUserProjects(UserId);
            ((SimpleMembershipProvider)Membership.Provider).DeleteAccount(name);
            ((SimpleMembershipProvider)Membership.Provider).DeleteUser(name, true);
            routeValues = this.GridRouteValues();
            return(RedirectToAction("Index", routeValues));
        }