public IHttpActionResult Post([FromBody] PersonCreateRequestModel requestModel)
        {
            // If we get this far we have a vaild model.
            // If we then saved the person to the database we would get an id for the person and return it to the caller.
            requestModel.PersonId = Guid.NewGuid();

            return(Ok(requestModel.PersonId));
        }
        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);
        }