Пример #1
0
        public List <LUserRoleVM> GetAll(WCFAuthInfoVM entity_WCFAuthInfoVM)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                List <string> strList_Error = new List <string>();

                bool ret_CheckPrivilege = false;

                ret_CheckPrivilege = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                List <LUserRoleVM> entityList_RoleVM = new List <LUserRoleVM>();

                if (ret_CheckPrivilege)
                {
                    CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                    UserRoleRespository roleRespo = new UserRoleRespository(dbContext, entity_BaseSession.ID);

                    entityList_RoleVM = roleRespo.GetLURoleVM_All();
                }

                return(entityList_RoleVM);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
        public List <LUserRoleVM> GetAll(WCFAuthInfoVM entity_WCFAuthInfoVM)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

                List <string> strList_Error = new List <string>();

                bool ret_CheckPrivilege = false;

                ret_CheckPrivilege = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                List <LUserRoleVM> entityList_RoleVM = new List <LUserRoleVM>();

                if (ret_CheckPrivilege)
                {
                    IPrivilegeFun entity_IPrivilegeFun = WCFBootstrapper.Container.GetExportedValue <IPrivilegeFun>();

                    SessionWUserInfo entity_SessionWUserInfo = entity_IPrivilegeFun.getAuthorizedInfoByUserID(entity_BaseSession.ID);

                    entity_BaseSession = entity_SessionWUserInfo;

                    bool allowEdit = entity_BaseSession.CheckAccessRight("LURoleManage", "Edit", "", null);
                    bool allowDel  = entity_BaseSession.CheckAccessRight("LURoleManage", "Delete", "", null);

                    CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                    UserRoleRespository roleRespo = new UserRoleRespository(dbContext, entity_BaseSession.ID);

                    entityList_RoleVM = roleRespo.GetLURoleVM_All();

                    entityList_RoleVM.ForEach(current =>
                    {
                        current.AllowDel  = allowDel;
                        current.AllowEdit = allowEdit;
                    });
                }

                return(entityList_RoleVM);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }