コード例 #1
0
        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));
        }
コード例 #2
0
        public void SetUp()
        {
            order = new Order();
            order.Pay("123", "jose");
            order.Finish();

            representation = OrderRepresentationMapper.Map(order, "http://restbuckson.net/");
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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())));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 public void SetUp()
 {
     order = new Order();
     order.Cancel("You are too slow.");
     representation = OrderRepresentationMapper.Map(order, "http://baseaddress/");
 }
コード例 #9
0
 public void SetUp()
 {
     order          = new Order();
     representation = OrderRepresentationMapper.Map(order, "http://restbuckson.net/");
 }