Пример #1
0
 /// <summary>
 /// продажа товара
 /// </summary>
 /// <param name="sellItem"></param>
 /// <param name="customer"></param>
 /// <returns></returns>
 public virtual bool SellTheItem(GoodsItem sellItem, Customer customer)
 {
     if (ChechGoodsIsEnough(sellItem))
     {
         if (CheckIfEnoughMoney(sellItem,DBalance))
         {
             if (DoesHaveEnoughChange(sellItem, DBalance))
             {
                 return _SellTheItem(sellItem, customer);
             }
             else
             {
                 CancelOrder(customer);
                 DoesNotHaveEnoughChange();
                 return false;
             }
         }
         else
         {
             //CancelOrder(customer);
             DoesNotHaveEnoughMoney();
             return false;
         }
     }
     else
     {
         CancelOrder(customer);
         DoesNotHaveEnoughGoods();
         return false;
     }
 }
Пример #2
0
 /// <summary>
 /// отмена заказа
 /// </summary>
 /// <param name="customer"></param>
 /// <returns></returns>
 public virtual bool CancelOrder(Customer customer)
 {
     List<Coin> change = CountChange(null, DBalance);
     if (customer.GetCoins(change))
     {
         Wallet.RemoveItems(a => change.Contains(a));
         DBalance = 0;
         return true;
     }
     return false;
 }
Пример #3
0
 /// <summary>
 /// продаем товар
 /// </summary>
 /// <param name="sellItem"></param>
 /// <param name="customer"></param>
 /// <returns></returns>
 private bool _SellTheItem(GoodsItem sellItem, Customer customer)
 {
     List<Coin> change;
     if (customer.GetTheGood(sellItem))
     {
         GoodsStorage.RemoveItems(a => a == sellItem);
         change = CountChange(sellItem, DBalance);
     }
     else
     {
         change = CountChange(null, DBalance);
     }
     if (customer.GetCoins(change))
     {
         Wallet.RemoveItems(a => change.Contains(a));
         DBalance = 0;
         NewMessage("Thank you!");
         return true;
     }
     return false;
 }
Пример #4
0
 /// <summary>
 /// Выдаем товар
 /// </summary>
 /// <param name="goodItem"></param>
 /// <param name="customer"></param>
 public virtual void TakeTheGood(GoodsItem goodItem,Customer customer)
 {
     if (customer.GetTheGood(goodItem))
     {
         GoodsStorage.RemoveItems(a => a.Equals(goodItem));
         DBalance = 0;
     }
 }