Esempio n. 1
0
        private async Task <bool> updateAgentRoles(Agent agent, List <RoleModel> RoleToAddList, List <RoleModel> RoleToRemoveList)
        {
            bool isUpdateSuccessful = false;

            List <Agent_role> agent_roleToAddList    = new List <Agent_role>();
            List <Agent_role> agent_roleToRemoveList = new List <Agent_role>();

            // add role to agent
            foreach (var roleModel in RoleToAddList)
            {
                Agent_role agent_role = new Agent_role();
                agent_role.AgentId = agent.ID;
                agent_role.RoleId  = roleModel.Role.ID;
                agent_roleToAddList.Add(agent_role);
            }

            // save new roles
            var agent_roleSavedList = await Bl.BlSecurity.InsertAgent_roleAsync(agent_roleToAddList);

            // delete agent role
            foreach (var roleModel in RoleToRemoveList)
            {
                var agent_roleFoundList = await Bl.BlSecurity.searchAgent_roleAsync(new Agent_role { AgentId = agent.ID, RoleId = roleModel.Role.ID }, ESearchOption.AND);

                agent_roleToRemoveList = new List <Agent_role>(agent_roleToRemoveList.Concat(agent_roleFoundList));
            }
            var deletedAgent_roleList = await Bl.BlSecurity.DeleteAgent_roleAsync(agent_roleToRemoveList);

            if (agent_roleSavedList.Count > 0 && deletedAgent_roleList.Count == 0)
            {
                isUpdateSuccessful = true;
            }

            return(isUpdateSuccessful);
        }
Esempio n. 2
0
        public async Task <List <Agent_role> > searchAgent_roleAsync(Agent_role Agent_role, ESearchOption filterOperator)
        {
            List <Agent_role> result = new List <Agent_role>();

            try
            {
                result = await DAC.DALSecurity.searchAgent_roleAsync(Agent_role, filterOperator);
            }
            catch (Exception ex) { Log.error(ex.Message, EErrorFrom.SECURITY); }
            return(result);
        }
Esempio n. 3
0
        public async Task <List <Agent_role> > searchAgent_roleAsync(Agent_role Agent_role, ESearchOption filterOperator)
        {
            List <Agent_role> result = new List <Agent_role>();

            try
            {
                result = (await _channel.get_filter_agent_roleAsync(_companyName, Agent_role.Agent_roleTypeToFilterArray(filterOperator))).ArrayTypeToAgent_role();
            }
            catch (FaultException) { Dispose(); throw; }
            catch (CommunicationException) { _channel.Abort(); throw; }
            catch (TimeoutException) { _channel.Abort(); }
            return(result);
        }
Esempio n. 4
0
 public async Task <List <Agent_role> > searchAgent_roleAsync(Agent_role Agent_role, ESearchOption filterOperator)
 {
     checkServiceCommunication();
     return(await _gateWaySecurity.searchAgent_roleAsync(Agent_role, filterOperator));
 }