示例#1
0
        public void SetUp()
        {
            var rootProductA = new RootProduct
            {
                Name        = "A",
                Description = "description A"
            };
            var rootProductB = new RootProduct
            {
                Name        = "B",
                Description = "description B"
            };

            this.RootProductsService.GetValid()
            .Returns(new SuccessResult <IEnumerable <RootProduct> >(new List <RootProduct> {
                rootProductA, rootProductB
            }));

            this.Response = this.Browser.Get(
                "/inventory/root-products",
                with =>
            {
                with.Header("Accept", "application/json");
            }).Result;
        }
        public void SetUp()
        {
            var rootProduct = new RootProduct {
                Name = "rp"
            };

            this.rootProductResponseModel = new ResponseModel <RootProduct>(rootProduct, null);
            this.RootProductService.GetById("rp", Arg.Any <IEnumerable <string> >()).Returns(new SuccessResult <ResponseModel <RootProduct> >(this.rootProductResponseModel));
            this.Response = this.Browser.Get(
                "/products/maint/root-products/rp",
                with =>
            {
                with.Header("Accept", "application/json");
            }).Result;
        }
示例#3
0
        public void SetUp()
        {
            this.requestResource = new SetRootProductRequestResource {
                Quantity = 3, RootProductUri = "/rp/50"
            };

            this.rootProduct = new RootProduct("/rp/50", 3);
            this.DemStockService.SetRetailerListRootProduct(234, "/rp/50", 3, null)
            .Returns(new SuccessResult <RootProduct>(this.rootProduct));

            this.Response = this.Browser.Put(
                "/retailers/234/dem-stock/products",
                with =>
            {
                with.Header("Accept", "application/json");
                with.JsonBody(this.requestResource);
            }).Result;
        }
        private void ProcessDemRootProducts(int invoiceId, IEnumerable <InvoiceLineResource> demLines)
        {
            var foundDemProducts = false;

            foreach (var invoiceResourceLine in demLines)
            {
                RootProduct rootProduct = null;

                var partUri = invoiceResourceLine.links.FirstOrDefault(l => l.Rel == "productUri")?.Href;
                if (partUri != null)
                {
                    var rootProductUri = this.productsProxy.GetRootProductUri(partUri);
                    if (rootProductUri != null)
                    {
                        rootProduct = new RootProduct(rootProductUri, invoiceResourceLine.quantity);
                    }
                }

                if (rootProduct == null)
                {
                    continue;
                }

                var retailerId = this.retailerProxy.GetRetailerId(invoiceResourceLine.links.First(l => l.Rel == "sales-customer").Href);
                if (!retailerId.HasValue)
                {
                    continue;
                }

                var retailerDemList = this.retailerDemListRepository.GetByRetailerId(retailerId.Value);
                this.log.Info($"Adding root product {rootProduct.RootProductUri} from invoice {invoiceId} line {invoiceResourceLine.number} to dem list {retailerDemList.Id} for retailer {retailerId}.");
                foundDemProducts = true;

                retailerDemList.IncrementRootProductQuantity(
                    rootProduct.RootProductUri,
                    "/employees/100",
                    rootProduct.Quantity);
            }

            if (foundDemProducts)
            {
                this.transactionManager.Commit();
            }
        }
示例#5
0
 public void SetUpContext()
 {
     this.Sut = new RootProduct("/root-products/200");
 }