Пример #1
0
        public CustomerDTO PostCustomer(Customer customer)
        {
            var outgoing = WebOperationContext.Current.OutgoingResponse;
            
            outgoing.SetStatusAsCreated(BuildCustomerUri(customer));

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