示例#1
0
        /// <inheritdoc />
        public virtual Task <HttpResponseMessage> CreatePerson(CreatePersonRequestDto requestBody)
        {
            var arguments = new object[] { requestBody };
            var func      = requestBuilder.BuildRestResultFuncForMethod("CreatePerson", new Type[] { typeof(CreatePersonRequestDto) });

            return((Task <HttpResponseMessage>)func(Client, arguments));
        }
示例#2
0
        public async Task <Result <int> > CreatePerson(string firstName, string lastName, string address, string phoneNumber, string zipCode, string state, int age, DateTime dateOfBirth)
        {
            var result = new Result <int>();

            var requestBody = new CreatePersonRequestDto
            {
                FirstName   = firstName,
                LastName    = lastName,
                Address     = address,
                Age         = age,
                PhoneNumer  = phoneNumber,
                State       = state,
                ZipCode     = zipCode,
                DateOfBirth = dateOfBirth
            };

            var response = await _personApiService.CreatePerson(requestBody);

            if (response.IsSuccessStatusCode)
            {
                var responseDto = JsonConvert.DeserializeObject <CreatePersonResponseDto>(await response.Content.ReadAsStringAsync());
                result.Response   = responseDto.Id;
                result.IsSucess   = true;
                result.StatusCode = Status.Success;
            }
            else if (response.StatusCode == HttpStatusCode.ServiceUnavailable)
            {
                result.StatusCode = Status.Unavailable;
            }
            else
            {
                result.StatusCode = Status.Unknown;
            }
            return(result);
        }
示例#3
0
 public async Task <HttpResponseMessage> CreatePerson(CreatePersonRequestDto requestBody)
 {
     return(await _personApiService.CreatePerson(requestBody));
 }