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(); }
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(); }
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(); }
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(); }
public void Handle(ItemsCheckedInToInventory message) { ReadDBContext dbcontext = Readcontext; InventoryItemDetailsDto d = GetDetailsItem(message.Id, dbcontext); d.CurrentCount += message.Count; d.Version = message.Version; dbcontext.SaveChanges(); }
public void Handle(InventoryItemRenamed message) { ReadDBContext dbcontext = Readcontext; InventoryItemDetailsDto d = GetDetailsItem(message.Id, dbcontext); d.Name = message.NewName; d.Version = message.Version; dbcontext.SaveChanges(); }
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(); }
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); }