예제 #1
0
 public ContactWithAddressDto GetContactWithAddressDto(Guid id)
 {
     using (var context = new ContactAggregateContext()) {
         Contact c = context.Contacts.Find(id);
         return(ContactWithAddressDto.Create(c.Id, c.Name, c.PrimaryAddress, c.Source));
     }
 }
예제 #2
0
        public async Task <Guid> GetNewContactIdFromContactApi(Order order)
        {
            // string uriString = "http://localhost:57596/api/contacts/";
            var client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:57596/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            ContactWithAddressDto contact = ContactWithAddressDto.Create(Guid.Empty, order.NewContactCustomerName,
                                                                         order.ShippingAddress, order.NewContactSource);


            HttpResponseMessage response = await client.PostAsJsonAsync("api/contacts", contact);

            if (response.IsSuccessStatusCode)
            {
                // Get the URI of the created resource.
                string resultJson = response.Content.ReadAsStringAsync().Result;
                return(JsonConvert.DeserializeObject <Guid>(resultJson));
            }


            return(Guid.Empty);
        }