public async Task <CheckingWithdrawal> AddCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
        {
            var inserted = await connection.InsertAsync(withdrawal);

            //withdrawal.IsNew = false;
            return(withdrawal);
        }
        public async Task DeleteCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
        {
            if (context.CheckingWithdrawal.Any(w => w.id == withdrawal.id))
            {
                await Task.Run(() => context.CheckingWithdrawal.Attach(withdrawal));

                await Task.Run(() => context.Entry(withdrawal).State = Microsoft.EntityFrameworkCore.EntityState.Deleted);

                if (withdrawal.checkingAccount != null)
                {
                    await Task.Run(() => context.Entry(withdrawal.checkingAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified);
                }
            }
        }
        public async Task UpdateCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
        {
            if (context.CheckingWithdrawal.Any(c => c.id == withdrawal.id))
            {
                await Task.Run(() => context.CheckingWithdrawal.Attach(withdrawal));

                await Task.Run(() => context.Entry(withdrawal).State = Microsoft.EntityFrameworkCore.EntityState.Modified);

                if (withdrawal.checkingAccount != null)
                {
                    await Task.Run(() => context.Entry(withdrawal.checkingAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified);
                }
            }
            else
            {
                throw new Exception("Unable to locate existing Checking Withdrawal record with provided Primary Key value");
            }
        }
        public async Task <CheckingWithdrawal> AddCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
        {
            if (!context.CheckingWithdrawal.Any(w => w.id == withdrawal.id))
            {
                await Task.Run(() => context.CheckingWithdrawal.Add(withdrawal));

                await Task.Run(() => context.Entry(withdrawal.checkingAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified);

                if (withdrawal.budgetExpense != null)
                {
                    await Task.Run(() => context.Entry(withdrawal.budgetExpense).State = Microsoft.EntityFrameworkCore.EntityState.Unchanged);
                }
            }
            else
            {
                throw new Exception("A withdrawal record already exists with the same Primary Key value");
            }
            return(withdrawal);
        }
Exemplo n.º 5
0
        public async Task PopulateVMAsync(CheckingWithdrawal withdrawal)
        {
            this.model             = withdrawal;
            this.accountModel      = withdrawal.checkingAccount;
            this.ItemId            = this.model.id;
            this.ItemType          = AccountItemType.Withdrawals;
            this.ItemAmount        = model.transactionAmount;
            this.EndingBalance     = model.endingBalance;
            this.ItemDescription   = model.payToTheOrderOf;
            this.PayToTheOrderOf   = this.model.payToTheOrderOf;
            this.TransactionDate   = model.transactionDate > DateTime.MinValue ? model.transactionDate : DateTime.Now;
            this.ItemDate          = this.TransactionDate;
            this.TransactionAmount = model.transactionAmount;
            this.ObjectColorCode   = this.model.ColorCode;

            this.BudgetItemId = model.budgetExpenseId;

            //await LoadBudgetData();
        }
        async Task <CheckingWithdrawalViewModel> AddCheckingWithdrawalAsync()
        {
            CheckingWithdrawalViewModel vm = new CheckingWithdrawalViewModel(this.dbFilePath);

            vm.IsNew     = true;
            vm.CanEdit   = true;
            vm.CanDelete = false;
            vm.ItemType  = AccountRegisterItemViewModel.AccountItemType.Withdrawals;

            CheckingWithdrawal withdrawal = new CheckingWithdrawal();

            withdrawal.checkingAccount   = model as CheckingAccount;
            withdrawal.checkingAccountId = model.id;
            withdrawal.transactionDate   = DateTime.Now;
            await vm.PopulateVMAsync(withdrawal);

            //this.AccountRegister.Add(vm);
            //await GroupAccountItemsAsync();
            //this.SelectedRegisterItem = vm;

            return(vm);
        }
 public async Task UpdateCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
 {
     var updated = await connection.UpdateAsync(withdrawal);
 }
 public async Task DeleteCheckingWithdrawalAsync(CheckingWithdrawal withdrawal)
 {
     var deleted = await connection.DeleteAsync(withdrawal);
 }
Exemplo n.º 9
0
 public void Put(int id, [FromBody] CheckingWithdrawal item)
 {
     throw new NotImplementedException();
 }