Exemple #1
0
        private List <UserRoleAction> GetRoleActionsToDelete(SystemUser user)
        {
            List <UserRoleAction> newList = new List <UserRoleAction>();

            foreach (UserRoleAction roleAction in user.OriginalRoleActions)
            {
                UserRoleAction action = user.RoleActions.Find(x => x.UserId == user.UserId && x.RoleId == roleAction.RoleId && x.RoleActionId == roleAction.RoleActionId);
                if (action == null)
                {
                    newList.Add(roleAction);
                }
            }
            return(newList);
        }
Exemple #2
0
        //private static SystemUser CheckUserType(DataTable dt)
        //{
        //    string[] roles = new string[dt.Rows.Count];
        //    SystemUser user = new SystemUser();
        //    int i = -1;

        //    if (dt.Rows.Count > 1)
        //    {
        //        foreach (DataRow dr in dt.Rows)
        //        {
        //            i += 1;
        //            roles[i] = dt.Rows[i]["Role"].ToString();
        //        }
        //    }
        //    else
        //        roles[0] = dt.Rows[0]["Role"].ToString();

        //    //if (roles.Contains("Developer"))
        //    //    user = new Developer(new OnlyMyCurrentJobs());
        //    //else if (roles.Contains("Campaign Manager"))
        //    //    user = new CampaignManager(new OnlyMyCurrentJobs());
        //    //else if (roles.Contains("Admin"))
        //    //    user = new AnyOtherUser(new AllCurrentJobs());
        //    //else
        //    //    user = new AnyOtherUser(new AllCurrentJobs());

        //    user.Roles = roles;
        //    return user;
        //}

        private List <UserRoleAction> GetUserRoleActions(SystemUser user)
        {
            DataTable             dt   = dbc.GetDataTable("SELECT * FROM vw_UserRoleActions WHERE UserId = " + user.UserId);
            List <UserRoleAction> list = new List <UserRoleAction>();

            foreach (DataRow dr in dt.Rows)
            {
                UserRoleAction ua = new UserRoleAction
                {
                    UserRoleActionId = (int)dr["UserRoleActionId"],
                    UserId           = (int)dr["UserId"],
                    RoleId           = (int)dr["RoleId"],
                    RoleActionId     = (int)dr["RoleActionid"],
                    Role             = dr["Role"].ToString(),
                    RoleAction       = dr["RoleAction"].ToString()
                };
                list.Add(ua);
            }
            return(list);
        }