Example #1
0
        private Client GetClientUserData(HttpActionContext actionContext)
        {
            string[] userCredentials = GetUserCredentials(actionContext);
            var      userName        = userCredentials[0];
            var      userPassword    = userCredentials[1];

            return(Task.Run(() => _companyClientsService.GetClientByName(userName)).Result);
        }
        public async Task <List <ClientPolicy> > GetPoliciesByClientName(string clientName)
        {
            var client = await _companyClientsService.GetClientByName(clientName);

            if (client != null)
            {
                return(await _companyPoliciesService.GetPoliciesByClientId(client.Id));
            }
            else
            {
                return(new List <ClientPolicy>());
            }
        }
Example #3
0
        public void Then_A_ClientRequestedByName()
        {
            var requestedName = "ClientName";
            var client        = ClientFactory.BuildClientRepositoryModelWithSpecificName(requestedName);

            _clientsRepositoryMocked
            .Expects
            .One
            .Method(x => x.GetClientByName(requestedName))
            .With(requestedName)
            .Will(Return.Value(Task.FromResult(client)));

            var clientResult = _sut.GetClientByName(requestedName).Result;

            Assert.IsNotNull(clientResult);
            Assert.AreEqual(requestedName, clientResult.Name);
        }
Example #4
0
        public async Task <IHttpActionResult> GetClientByName(string name)
        {
            try
            {
                var userInfo = await _companyClientsService.GetClientByName(name);

                if (userInfo == null)
                {
                    return(NotFound());
                }

                return(Ok(userInfo));
            }
            catch (Exception exception)
            {
                return(ManageExceptionAndBuildResult(nameof(name), name, exception));
            }
        }