public OrderRepresentation CreateOrder(OrderRepresentation order) { var httpClient = GetHttpClient(); var content = new ObjectContent<OrderRepresentation>(order, new [] {new RestbucksMediaTypeFormatter()}); content.Headers.ContentType = new MediaTypeHeaderValue(RepresentationBase.RestbucksMediaType); var responseMessage = httpClient.Post(_baseUri+"/order", content); var responseContent = responseMessage.Content.ReadAs<OrderRepresentation>(new [] {new RestbucksMediaTypeFormatter()}); return responseContent; }
public OrderRepresentation Create(OrderRepresentation orderRepresentation, Uri requestUri) { var newOrder = _orderRepresentationMapper.GetDomainObject(orderRepresentation); var orderId = _repository.Store(newOrder); var orderUri = RestbucksResources.GetResourceUri<OrderResource>(requestUri, orderId.ToString()); var paymentUri = RestbucksResources.GetResourceUri<PaymentResource>(requestUri, orderId.ToString()); var result = _orderRepresentationMapper.GetRepresentation(newOrder); result.UpdateLink = orderUri; result.SelfLink = orderUri; result.CancelLink = orderUri; result.PaymentLink = paymentUri; return result; }
public Order GetDomainObject(OrderRepresentation orderRepresentation) { return new Order(orderRepresentation.Location, orderRepresentation.Items.Select(_itemMapper.GetDomainObject)); }