Example #1
0
        public void GetContactByUserId_Test()
        {
            GetContactByUserIdDataRequest request = new GetContactByUserIdDataRequest {
                UserId = "abe05e86-a890-4d61-8c78-b04923cbb3d6"
            };

            ContactData response = manager.GetContactByUserId(request);

            Assert.IsTrue(response.Id == "530fcad1d4332320e0336a6a");
        }
Example #2
0
        public ContactData GetContactByUserId(GetContactByUserIdDataRequest request)
        {
            ContactData result = null;

            try
            {
                IContactRepository repo = Factory.GetRepository(request, RepositoryType.Contact);

                result = repo.FindContactByUserId(request) as ContactData;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Example #3
0
        public GetContactByUserIdDataResponse GetContactByUserId(string userId)
        {
            Uri getContactUri = new Uri(string.Format("{0}/Contact/{1}/{2}/{3}/Contact/User/{4}?UserId={5}",
                                                      Url,
                                                      Context,
                                                      Version,
                                                      ContractNumber,
                                                      userId,
                                                      HeaderUserId));
            HttpClient getContactClient = GetHttpClient(getContactUri);

            GetContactByUserIdDataRequest getContactRequest = new GetContactByUserIdDataRequest
            {
                SQLUserId      = userId,
                Context        = Context,
                Version        = Version,
                ContractNumber = ContractNumber
            };

            DataContractJsonSerializer getContactJsonSer = new DataContractJsonSerializer(typeof(GetContactByUserIdDataRequest));
            MemoryStream getContactMs = new MemoryStream();

            getContactJsonSer.WriteObject(getContactMs, getContactRequest);
            getContactMs.Position = 0;

            //use a Stream reader to construct the StringContent (Json)
            StreamReader  getContactSr      = new StreamReader(getContactMs);
            StringContent getContactContent = new StringContent(getContactSr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json");

            getContactMs.Dispose();

            //Post the data
            var getContactResponse        = getContactClient.GetStringAsync(getContactUri);
            var getContactResponseContent = getContactResponse.Result;

            string getContactResponseString = getContactResponseContent;
            GetContactByUserIdDataResponse responseContact = null;

            using (var getContactMsResponse = new MemoryStream(Encoding.Unicode.GetBytes(getContactResponseString)))
            {
                var getContactSerializer = new DataContractJsonSerializer(typeof(GetContactByUserIdDataResponse));
                responseContact = (GetContactByUserIdDataResponse)getContactSerializer.ReadObject(getContactMsResponse);
            }
            return(responseContact);
        }
Example #4
0
        public GetContactByUserIdDataResponse Get(GetContactByUserIdDataRequest request)
        {
            GetContactByUserIdDataResponse response = new GetContactByUserIdDataResponse();

            response.Version = request.Version;
            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:Get()::Unauthorized Access");
                }

                response.Contact = Manager.GetContactByUserId(request);
            }
            catch (Exception ex)
            {
                CommonFormat.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }