Exemple #1
0
        public void GivenAnOrderWithOneProduct_WhenPaymentIsVerified_ReducesStock()
        {
            int productId = PRODUCT_ID_ONE;

            var payment = new Payment(amount: 12, paymentState: PaymentState.Verified);

            var orderedProduct = new Product(productId: productId,
                                             quantity: ORDERED_PRODUCT_QUANTITY,
                                             name: PRODUCT_NAME);
            List <Product> orderedProducts = new List <Product> {
                orderedProduct
            };

            var stockProducts = GetDummyStock();

            var order = new Order(payment: payment, products: orderedProducts);
            var stock = new Stock(stockProducts);

            var inventory = new Domain.Inventory(stock: stock);

            inventory.AdjustStockLevels(order: order);

            var stockProduct = inventory.Stock.StockProducts.First(predicate: sp => sp.ProductId == PRODUCT_ID_ONE);

            stockProduct.TotalQuantity.Should().Be(TOTAL_QUANTITY - ORDERED_PRODUCT_QUANTITY);
        }
 public static InventoryDto ToDto(this Domain.Inventory inv)
 {
     return(new InventoryDto
     {
         Link = inv.Link,
         Location = inv.Location,
         Quantity = inv.Quantity
     });
 }
Exemple #3
0
        public static Data.Models.Inventory Map(Domain.Inventory dmInv)
        {
            Data.Models.Inventory deInv = new Models.Inventory();
            deInv.Invid        = dmInv.invId;
            deInv.FkIngredient = dmInv.FkIngredient;
            deInv.Resfid       = dmInv.resfId;
            deInv.Cost         = dmInv.cost_inv;
            deInv.Stock        = dmInv.stock;

            return(deInv);
        }
 public static InventoryModel FromDomain(Domain.Inventory domain)
 {
     return(new InventoryModel
     {
         Description = domain.Description,
         EndDate = domain.EndDate == DateTime.MinValue ? null as DateTime? : domain.EndDate,
         Id = domain.Id,
         InventorySatus = InvenotryStatusModel.FormDto(domain.InventorySatus),
         StartDate = domain.StartDate == DateTime.MinValue ? null as DateTime? : domain.StartDate,
         Products = domain.Products?.Select(InventoryProductModel.FormDomain).ToList() ?? new List <InventoryProductModel>(),
         ZoneId = domain.ZoneId
     });
 }
Exemple #5
0
        public Domain.Inventory GetInventory(ICollection <Data.Entities.InventoryItem> invEntity)
        {
            Inventory res = new Domain.Inventory();

            foreach (var i in invEntity)
            {
                PizzaComponent pc = GenerateComponent(i.C.Name, i.C.Cost, i.C.Kind);
                res.SetInventory(pc, i.Quantity);
                if (i.C.Kind.ToLower() == "size")
                {
                    res.AddSize((Size)pc);
                }
                else
                {
                    res.SetInventory(pc, i.Quantity);
                }
            }
            return(res);
        }
        public override async Task SeedAsync(InventoryDbContext context)
        {
            var inventorySet = context.Set <Domain.Inventory>();

            if (inventorySet.Any())
            {
                return;
            }

            var inventory1 = new Domain.Inventory(
                new System.Guid("25E6BA6E-FDDB-401D-99B2-33DDC9F29322"))
            {
                Link     = "http://nashtechglobal.com",
                Location = "London, UK",
                Quantity = 100,
            };

            var inventory2 = new Domain.Inventory(
                new System.Guid("CAB3818F-E459-412F-972F-D4B2D36AA735"))
            {
                Link     = "http://nashtechvietnam.com",
                Location = "Ho Chi Minh City, Vietnam",
                Quantity = 1000,
            };

            if (!inventorySet.Any(x => x.Id == inventory1.Id))
            {
                await inventorySet.AddAsync(inventory1);
            }

            if (!inventorySet.Any(x => x.Id == inventory2.Id))
            {
                await inventorySet.AddAsync(inventory2);
            }

            await context.SaveChangesAsync();
        }
 public InventoryService(Domain.Inventory inventory)
 {
     Inventory = inventory;
     _bag      = new InventoryList(Inventory.Bag);
 }