Exemplo n.º 1
0
        public CustomerDTO PostCustomer(Customer customer)
        {
            var outgoing = WebOperationContext.Current.OutgoingResponse;
            
            outgoing.SetStatusAsCreated(BuildCustomerUri(customer));

            return MapCustomer(customer);
        }
Exemplo n.º 2
0
 private CustomerDTO MapCustomer(Customer customer)
 {
     return new CustomerDTO
         {
             Self = BuildCustomerUri(customer),
             Organisation = customer.Organisation,
             Invoices = BuildInvoiceUris(customer).ToList()
         };
 }
Exemplo n.º 3
0
 private IEnumerable<Uri> BuildInvoiceUris(Customer customer)
 {
     if (customer.Invoices != null)
     {
         foreach (var invoice in customer.Invoices)
         {
             yield return BuildInvoiceUri(customer, invoice);
         }
     }
 }
Exemplo n.º 4
0
 private Uri BuildCustomerUri(Customer customer)
 {
     return new Uri(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri, "customers/" + customer.Organisation);
 }
Exemplo n.º 5
0
 private Uri BuildInvoiceUri(Customer customer, Invoice invoice)
 {
     return new Uri(WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri,
                     "customers/" + customer.Organisation + "/invoices/" + invoice.Id);
 }