private void ProcessResult(WebApiResponse <Guid> result)
 {
     if (result.HttpStatusCode == HttpStatusCode.OK)
     {
         Console.WriteLine($"{result.ApiResponse}");
     }
     else
     {
         Console.WriteLine($"{result.Error}");
     }
 }
        private async Task <WebApiResponse <Guid> > PostToService(PersonCreateRequestModel model)
        {
            var    httpClient            = GetHttpClient();
            string requestEndpoint       = "person"; // full request will be http://localhost:5802/api/person
            HttpResponseMessage response = await httpClient.PostAsJsonAsync(requestEndpoint, model);

            WebApiResponse <Guid> wrappedResponse;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var id = await response.Content.ReadAsAsync <Guid>();

                wrappedResponse = new WebApiResponse <Guid>(id, response.StatusCode);
            }
            else
            {
                var errors = await response.Content.ReadAsStringAsync();

                wrappedResponse = new WebApiResponse <Guid>(errors, response.StatusCode, true);
            }
            return(wrappedResponse);
        }
        static void Main(string[] args)
        {
            Program p = new Program();

            var personModel = p.Get();
            PersonCreateRequestModel goodModel = new PersonCreateRequestModel()
            {
                Firstname = "Alfred", Lastname = "Andrews"
            };
            PersonCreateRequestModel badModel = new PersonCreateRequestModel()
            {
                Firstname = "", Lastname = "Andrews"
            };

            var task = p.PostToService(goodModel);
            WebApiResponse <Guid> goodResult = task.WaitAndUnwrapException();

            p.ProcessResult(goodResult);

            var task2 = p.PostToService(badModel);
            WebApiResponse <Guid> badResult = task2.WaitAndUnwrapException();

            p.ProcessResult(badResult);
        }