예제 #1
0
        public async Task UpdateInventoryStatus(ProductInventory inventoryEntry, InventoryStatus newStatus, int binId) {
            var oldStatus = inventoryEntry.Status;
            inventoryEntry.Status = newStatus;
            inventoryEntry.BinId = binId;

            this.Context.ProductInventories.Attach(inventoryEntry);
            this.Context.Entry(inventoryEntry).State = EntityState.Modified;
            await this.Context.SaveChangesAsync();
            await PostSaveAsync(inventoryEntry, oldStatus);
        }
예제 #2
0
        private async Task PostSaveAsync(ProductInventory inventoryEntry, InventoryStatus oldStatus) {
            await this.AuditService.AppendAuditEntryAsync(new InventoryAudit {
                EventDate = DateTime.Now,
                Inventory = inventoryEntry,
                InventoryId = inventoryEntry.Id,
                OldStatus = oldStatus,
                NewStatus = inventoryEntry.Status
            });

            this.NotifierService.SendProductInventoryChange(
                new InventorySummary {
                    ProductId = inventoryEntry.ProductId,
                    Count = GetProductCount(inventoryEntry.ProductId)
                });
        }
예제 #3
0
        public async Task AddSerializedItem (int productId, string serialId, int binId)
        {
            var inventoryEntry = await GetInventoryBySerialIdAsync(serialId);

            if (inventoryEntry != null) {
                throw new Exception("Serial Id is already in used");
            }
            inventoryEntry = new ProductInventory
            {
                ProductId = productId,
                SerialId = serialId,
                BinId = binId,
                Status = InventoryStatus.InStock
            };
            this.Context.ProductInventories.Add(inventoryEntry);

            await this.Context.SaveChangesAsync();
            await PostSaveAsync(inventoryEntry, inventoryEntry.Status);
        }