Beispiel #1
0
        private void DeleteBudget()
        {
            string message;

            if (Budget.Transactions?.Count > 0)
            {
                message =
                    $"Wenn sie das Budget von {Budget.Year} löschen, werden alle zugehörigen Buchungen ({Budget.Transactions.Count}) ebenfalls gelöscht. " +
                    "Wollen sie das Budget trotzdem löschen?";
            }
            else
            {
                message = $"Wollen sie das Budget von {Budget.Year} wirklich löschen?";
            }

            if (MessageBox.Show(message, "Budget löschen?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                var deletedBudget       = Budget;
                var deletedTransactions = Budget.Transactions?.ToList() ?? new List <Transaction>();

                UnitOfWork.Transactions.RemoveRange(deletedTransactions);
                UnitOfWork.Budgets.Remove(deletedBudget);
                UnitOfWork.Complete();

                foreach (var t in deletedTransactions)
                {
                    TransactionList.Remove(t);
                }

                BudgetList.Remove(deletedBudget);
                Budget = BudgetList.Count > 0 ? BudgetList[0] : null;
            }
        }
        public TransactionList SyncTransactions(TransactionList transactions)
        {
            try
            {
                var transList = new TransactionList();
                var transIDs = transactions.Select(x => x.TransactionId).ToList();
                using (EntityContext context = new EntityContext())
                {
                    var query = (from i in context.Transaction
                                 where transIDs.Contains(i.TransactionId)
                                 select i).ToList();

                    //investigate if there is a better way to convert the generic list to ObservableCollection
                    foreach (var item in query)
                    {
                        var tempItem = transactions.FirstOrDefault(x => x.TransactionId == item.TransactionId);
                        if (tempItem.ModifiedDate < item.ModifiedDate)
                            transactions.Remove(tempItem);
                    }
                }

                return SaveTransactions(transactions);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
      public TaxFormPackage(TransactionList parentTransactionList, bool isPending, string sponsorGUID, 
        string authorizedDependentClientGUID, FormType formType, int qty) : base(parentTransactionList)
      {
        //sanity check: if there are already printed forms in the shopping cart, everything else must be printed during this session... too complicated to manage otherwise
        if (isPending && parentTransactionList.Any(t => !t.IsPending))
        {
          ShowUserMessage("Since forms have already been printed.\rAll subsequent forms must also be printed.\rPlease select 'Print Immediately' only.");
          return;
        }

        //combine all NF1's requested during this customer session into one bundle
        var existingNF1Package = parentTransactionList.OfType<TaxFormPackage>().FirstOrDefault(w => w.FormType == FormType.NF1); //realized, filtering on IsPending is counterproductive. An NF1 package will only be in this list if generated during this customer "session" and therefore the total qty of forms is what should factor into the qty discount calc
        if (existingNF1Package != null)
        {
          qty += existingNF1Package.Qty; //add the existing quantity to this new package...
          PackageCode = existingNF1Package.PackageCode; //to facilitate adding these new forms to a previously printed package
          isPending = existingNF1Package.IsPending; //pending status must be same as whatever was already initiated
        }

        PendingAction = "Print";

        IsPending = isPending;
        Description = String.Format("New {0} Package {1}", Enum.GetName(typeof(FormType), formType), formType == FormType.NF1 ? "(" + qty.ToString(CultureInfo.InvariantCulture) + ")" : ""); //Extensions.Pluralize("{count} New {0} Form{s}", Qty, Enum.GetName(typeof(TaxForm.FormType), FormType));
        SponsorGUID = sponsorGUID;
        AuthorizedDependentClientGUID = authorizedDependentClientGUID;
        FormType = formType;
        Qty = qty;
        Price = LookupPackageServiceFee(formType, qty);

        if (!isPending)
        {
          new System.Threading.Thread(delegate(object existingPackage) //pop off a background thread to create the records
          {
            if (Execute())
            {
              //hit the DB to create all the new Package/Forms records
              if (existingPackage != null)
                parentTransactionList.Remove(existingPackage as TaxFormPackage); //delete the old package
              AfterConstructor();
            }
          }).Start(existingNF1Package);
        }

      }