예제 #1
0
 // Methods
 public void Execute(Customer customer)
 {
     if (customer.CustomerType.Equals("INACTIVE"))
     {
         throw new Exception("INACTIVE ID");
     }
     Boolean decrement = customer.PlanId.ToUpper().StartsWith("BLOCK");
     Transaction transaction = new Transaction();
     if (!decrement)
     {
         transaction.find(string.Concat(new object[] { "([PeopleID]='", customer.PeopleID, "') AND ([DateTime] > '", customer.MealCost.StartTime, "') AND [TTID] = 'MEALCHRG'" }));
         decrement = transaction.PeopleID == null;
     }
     if (decrement)
     {
         if (customer.CurrentMeals <= 0)
         {
             throw new Exception("Zero Meals Left");
         }
         transaction.PeopleID = customer.PeopleID;
         transaction.Amount = 0M;
         transaction.PlanID = customer.PlanId;
         transaction.LocationID = this.location;
         transaction.Ttid = this.ttid;
         transaction.currentMeals();
         customer.CurrentMeals--;
     }
 }