示例#1
0
        public void Handle(InventoryItemCreated message)
        {
            //BullShitDatabase.list.Add(new InventoryItemListDto(message.Id, message.Name));
            ReadDBContext dbcontext = Readcontext;

            dbcontext.InventoryItemList.Add(new InventoryItemListDto(message.Id, message.Name));
            dbcontext.SaveChanges();
        }
示例#2
0
        public void Handle(InventoryItemCreated message)
        {
            //BullShitDatabase.details.Add(message.Id, new InventoryItemDetailsDto(message.Id, message.Name, 0,0));
            ReadDBContext dbcontext = Readcontext;

            dbcontext.InventoryItemDetails.Add(new InventoryItemDetailsDto(message.Id, message.Name, 0, 0));
            dbcontext.SaveChanges();
        }
示例#3
0
        public void Handle(InventoryItemDeactivated message)
        {
            //BullShitDatabase.list.RemoveAll(x => x.Id == message.Id);
            ReadDBContext dbcontext = Readcontext;
            var           item      = dbcontext.InventoryItemList.FirstOrDefaultAsync(x => x.Id == message.Id).Result;

            dbcontext.InventoryItemList.Remove(item);
            dbcontext.SaveChanges();
        }
示例#4
0
        public void Handle(InventoryItemRenamed message)
        {
            //var item = BullShitDatabase.list.Find(x => x.Id == message.Id);
            ReadDBContext dbcontext = Readcontext;
            var           item      = dbcontext.InventoryItemList.FirstOrDefaultAsync(x => x.Id == message.Id).Result;

            item.Name = message.NewName;
            dbcontext.SaveChanges();
        }
示例#5
0
        public void Handle(ItemsCheckedInToInventory message)
        {
            ReadDBContext           dbcontext = Readcontext;
            InventoryItemDetailsDto d         = GetDetailsItem(message.Id, dbcontext);

            d.CurrentCount += message.Count;
            d.Version       = message.Version;
            dbcontext.SaveChanges();
        }
示例#6
0
        public void Handle(InventoryItemRenamed message)
        {
            ReadDBContext           dbcontext = Readcontext;
            InventoryItemDetailsDto d         = GetDetailsItem(message.Id, dbcontext);

            d.Name    = message.NewName;
            d.Version = message.Version;
            dbcontext.SaveChanges();
        }
示例#7
0
        public void Handle(ItemsRemovedFromInventory message)
        {
            ReadDBContext           dbcontext = Readcontext;
            InventoryItemDetailsDto d         = GetDetailsItem(message.Id, dbcontext);

            d.CurrentCount -= message.Count;
            d.Version       = message.Version;
            dbcontext.InventoryItemDetails.Remove(d);
            dbcontext.SaveChanges();
        }
示例#8
0
        private InventoryItemDetailsDto GetDetailsItem(Guid id, ReadDBContext dbcontext)
        {
            //InventoryItemDetailsDto d;
            var item = dbcontext.InventoryItemDetails.FirstOrDefaultAsync(x => x.Id == id).Result;

            //if (!BullShitDatabase.details.TryGetValue(id, out d))
            if (item == null)
            {
                throw new InvalidOperationException("did not find the original inventory this shouldnt happen");
            }

            return(item);
        }