Exemplo n.º 1
0
 private void SetAgentProperties(CommitAgentRequestData request, bool forcePasswordReset = false)
 {
     request.Agent.AuthenticationType = nskCommonEnum.AuthenticationType.Password;
     request.Agent.ForcePasswordReset = forcePasswordReset;
     if (request.Agent.AgentRoles == null || request.Agent.AgentRoles.Length == 0)
     {
         request.Agent.AgentRoles = GetNewRole(_newskiesSettings.DefaultAgentRoleCode);
     }
     if (string.IsNullOrEmpty(request.Agent.DepartmentCode))
     {
         request.Agent.DepartmentCode = _newskiesSettings.DefaultAgentDepartmentCode;
     }
     if (string.IsNullOrEmpty(request.Agent.LocationCode))
     {
         request.Agent.LocationCode = _newskiesSettings.DefaultAgentLocationCode;
     }
     if (string.IsNullOrEmpty(request.Agent.AgentIdentifier.DomainCode))
     {
         request.Agent.AgentIdentifier.DomainCode = _newskiesSettings.AgentDomain;
     }
     if (string.IsNullOrEmpty(request.Agent.AgentIdentifier.OrganizationCode))
     {
         request.Agent.AgentIdentifier.OrganizationCode = _newskiesSettings.DefaultAgentOrgCode;
     }
     if (request.Person != null && string.IsNullOrEmpty(request.Person.CultureCode))
     {
         request.Person.CultureCode = _newskiesSettings.DefaultCulture;
     }
 }
Exemplo n.º 2
0
 private async Task <CommitAgentResponse> CommitAgent(CommitAgentRequestData commitAgentRequestData, string signature)
 {
     return(await _client.CommitAgentAsync(new CommitAgentRequest
     {
         ContractVersion = _navApiContractVer,
         MessageContractVersion = _navMsgContractVer,
         Signature = signature,
         EnableExceptionStackTrace = false,
         CommitAgentReqData = commitAgentRequestData
     }));
 }
Exemplo n.º 3
0
        public async Task <dto.Agent> UpdateAgent(dto.Agent agent)
        {
            // Disallow self to update status/role/lock
            if (agent.AgentID == await _sessionBag.AgentId())
            {
                var self = await GetAgent(agent.AgentID);

                if (IsDifferentRolesOrStatusOrLocked(agent, self.Agent))
                {
                    throw new dto.ResponseErrorException(dto.Enumerations.ResponseErrorCode.AgentUpdateNotAllowed, "Agent update operation not allowed. ");
                }
            }

            var signature = await _sessionBag.Signature();

            var mappedAgent = Mapper.Map <Agent>(agent);

            mappedAgent.AgentIdentifier = new AgentIdentifier
            {
                AgentName        = agent.LoginName,
                OrganizationCode = await _sessionBag.OrganizationCode(),
                State            = nskCommonEnum.MessageState.Clean
            };
            var request = new CommitAgentRequestData {
                Agent = mappedAgent
            };

            SetAgentProperties(request);
            request.Agent.State      = nskCommonEnum.MessageState.Modified;
            request.Agent.AgentRoles = await SetAgentRoleCode(agent.AgentID, request.Agent.AgentRoles);
            await CommitAgent(request, signature);

            var getAgent = await GetAgent(agent.AgentID);

            return(getAgent.Agent);
        }
Exemplo n.º 4
0
 public async Task <IActionResult> Post([FromBody] CommitAgentRequestData commitAgentRequestData)
 {
     return(new OkObjectResult(await _agentService.AddAgent(commitAgentRequestData)));
 }