Exemplo n.º 1
0
        // POST /api/invoices
        public HttpResponseMessage Post(InvoiceDTO invoice)
        {
            m_InvoiceRepository.Add(invoice.ToEntity());
            var response = new HttpResponseMessage<InvoiceDTO>(invoice, HttpStatusCode.Created);

            response.Headers.Location = new Uri(Request.RequestUri + invoice.InvoiceNumber);

            return response;
        }
Exemplo n.º 2
0
        public static InvoiceDTO ToDto(this Invoice invoice)
        {
            if (invoice == null)
                return new InvoiceDTO();

            var dto = new InvoiceDTO
                          {
                              InvoiceNumber = invoice.InvoiceNumber,
                              InvoiceDate = invoice.InvoiceDate
                          };

            return dto;
        }