Ejemplo n.º 1
0
 public Boolean RemoveGoods(InventoryGoods goods, Int32 count)
 {
     // check if the goods in inventory
     if (MyGoods.Exists(t => t.GoodsName == goods.GoodsName))
     {
         // check if goods count > count
         InventoryGoods ig = MyGoods.Find(t => t.GoodsName == goods.GoodsName);
         if (ig.GoodsCount > count)
         {
             ig.InventoryGoodsSellOut(count);
             OnInventoryGoodsSold(goods);
             return(true);
         }
         else if (ig.GoodsCount == count)
         {
             MyGoods.Remove(ig);
             OnInventoryGoodsSold(goods);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         // no such goods or no enough goods to take out
         return(false);
     }
 }
Ejemplo n.º 2
0
 public Boolean AddGoods(MarketGoods goods, Int32 count)
 {
     if (goods.GoodsCount == -1 || goods.GoodsCount > count) // enough goods to add
     {
         if (count <= LeftCapacity)                          // enough room to place the goods
         {
             if (MyGoods.Exists(t => t.GoodsName == goods.GoodsName))
             {
                 var g = MyGoods.Find(t => t.GoodsName == goods.GoodsName);
                 g.InventoryGoodsAdd(goods, count);
             }
             else
             {
                 var g = new InventoryGoods(goods, count);
                 MyGoods.Add(g);
             }
             return(true);
         }
     }
     // no enough goods or no enough space
     return(false);
 }