public Object GetHandler(int orderId) { var order = orderRepository.GetById(orderId); if (order == null) { return((Response)HttpStatusCode.NotFound); } if (order.Status == OrderStatus.Canceled) { return(Response.MovedTo(new ResourceLinker(Request.BaseUri()).BuildUriString(TrashModule.path, TrashModule.GetCancelledPath, new { orderId }))); } if (Request.IsNotModified(order)) { return(Response.NotModified()); } return(Negotiate .WithModel(OrderRepresentationMapper.Map(order, Request.BaseUri())) .WithCacheHeaders(order)); }
public void SetUp() { order = new Order(); order.Pay("123", "jose"); order.Finish(); representation = OrderRepresentationMapper.Map(order, "http://restbuckson.net/"); }
public void SetUp() { var appHelper = new ResourceHandlerTestBase(); var app = appHelper.CreateAppProxy(); order = new Order(); representation = OrderRepresentationMapper.Map(order, appHelper.Container.Resolve <ResourceLinker>(), app.Get("/order").Context); }
public Response GetCanceled(int orderId) { var order = orderRepository.Retrieve(o => o.Id == orderId && o.Status == OrderStatus.Canceled) .FirstOrDefault(); return(order == null ? HttpStatusCode.NotFound : Response.AsXml(OrderRepresentationMapper.Map(order, Request.BaseUri()))); }
private object GetCanceled(int orderId) { var order = orderRepository.Retrieve(o => o.Id == orderId && o.Status == OrderStatus.Canceled) .FirstOrDefault(); if (order == null) { return(HttpStatusCode.NotFound); } return(Negotiate.WithModel(OrderRepresentationMapper.Map(order, Request.BaseUri())).WithCacheHeaders(order)); }
public void ACallToGetCanceled_ShouldReturnTheOrder() { // Arrange var order = new Order { Id = 123, Status = OrderStatus.Canceled }; var expectedBody = OrderRepresentationMapper.Map(order, "http://bogus/").ToXmlString(); order.Status = OrderStatus.Unpaid; var app = CreateAppProxy(new RepositoryStub <Order>(order)); // Act var response = app.Delete("/order/123/"); var responseToGet = app.Get("/trash/order/123/"); responseToGet.StatusCode.Should().Be.EqualTo(HttpStatusCode.OK); responseToGet.Body.AsString().Should().Be.EqualTo(expectedBody); }
public Object GetHandler(int orderId) { var order = orderRepository.GetById(orderId); if (order == null) { return((Response)HttpStatusCode.NotFound); } if (order.Status == OrderStatus.Canceled) { return(Response.MovedTo(linker.BuildUriString(Context, "ReadCancelledOrder", new { orderId }))); } if (Request.IsNotModified(order)) { return(Response.NotModified()); } return(Negotiate .WithModel(OrderRepresentationMapper.Map(order, linker, Context)) .WithCacheHeaders(order)); }
public void SetUp() { order = new Order(); order.Cancel("You are too slow."); representation = OrderRepresentationMapper.Map(order, "http://baseaddress/"); }
public void SetUp() { order = new Order(); representation = OrderRepresentationMapper.Map(order, "http://restbuckson.net/"); }