Beispiel #1
0
        private void ExecuteDeleteExpense()
        {
            MessageBoxResult result = MessageBox.Show("Deleting Expense will delete all of the details also, \nAre you sure to delete", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                if (CurrentExpense != null)
                {
                    using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
                        MahalluManager.Model.Expense expense = unitofWork.Expenses.Get(CurrentExpense.Id);
                        unitofWork.Expenses.Remove(expense);
                        unitofWork.Complete();

                        ExpenseType totatExpenseType = new ExpenseType()
                        {
                            Expense = CurrentExpense, Operation = MahalluManager.Model.Common.Operation.Delete
                        };
                        eventAggregator.GetEvent <PubSubEvent <ExpenseType> >().Publish(totatExpenseType);

                        ExpenseList.Remove(CurrentExpense);
                        CurrentExpense = null;
                    }
                }
            }
        }
Beispiel #2
0
        private MahalluManager.Model.Expense GetExpense()
        {
            var expense = new MahalluManager.Model.Expense();

            if (!ExpenseCategory.DetailsRequired)
            {
                expense.ToatalAmount = Convert.ToDecimal(TotalAmount?.Trim());
            }
            expense.BillNo       = ExpenseBillNo?.Trim();
            expense.CategoryName = ExpenseCategory.Name?.Trim();
            expense.CreatedOn    = CreatedOn;
            return(expense);
        }
Beispiel #3
0
 private void ExecuteSaveExpense()
 {
     if (ValidateExpense())
     {
         using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) {
             MahalluManager.Model.Expense expense = GetExpense();
             unitOfWork.Expenses.Add(expense);
             unitOfWork.Complete();
             ExpenseList.Add(expense);
             CurrentExpense = expense;
             ExpenseType totatExpenseType = new ExpenseType()
             {
                 Expense = CurrentExpense
             };
             eventAggregator.GetEvent <PubSubEvent <ExpenseType> >().Publish(totatExpenseType);
         }
     }
 }