public static void InitiateReplenishment(Int32 pzn, int quantity, PharmacyContainer db)
        {
            Drug drug = DrugService.GetDrug(pzn, db);

            if (HasOpenOrders(drug, db))
            {
                AdjustExistingOrderFor(drug, quantity, db);
            }
            else
            {
                CreatePositionOnOpenOrNewOrder(drug, quantity, db);
            }
            db.SaveChanges();
        }
 public static void ProceedToNextState(Int32 id)
 {
     using (PharmacyContainer db = new PharmacyContainer())
     {
         ReplenishmentOrder order = GetOrder(id, db);
         order.State = order.State.Next();
         if (order.State == OrderState.Finished)
         {
             foreach (Position p in order.Positions)
             {
                 DrugService.Replenish(p.Drug.PZN, p.Quantity, order.ActualDelivery, db);
             }
         }
         db.SaveChanges();
     }
 }