コード例 #1
0
        public async Task <CheckingDeposit> AddCheckingDepositAsync(CheckingDeposit deposit)
        {
            var inserted = await connection.InsertAsync(deposit);

            //deposit.IsNew = false;
            return(deposit);
        }
コード例 #2
0
        public async Task DeleteCheckingDepositAsync(CheckingDeposit deposit)
        {
            if (context.CheckingDeposit.Any(d => d.id == deposit.id))
            {
                await Task.Run(() => context.CheckingDeposit.Attach(deposit));

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

                if (deposit.checkingAccount != null)
                {
                    await Task.Run(() => context.Entry(deposit.checkingAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified);
                }
            }
        }
コード例 #3
0
        public async Task UpdateCheckingDepositAsync(CheckingDeposit deposit)
        {
            if (context.CheckingDeposit.Any(c => c.id == deposit.id))
            {
                await Task.Run(() => context.CheckingDeposit.Attach(deposit));

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

                if (deposit.checkingAccount != null)
                {
                    await Task.Run(() => context.Entry(deposit.checkingAccount).State = Microsoft.EntityFrameworkCore.EntityState.Modified);
                }
            }
            else
            {
                throw new Exception("Unable to locate existing Checking Deposit record with provided Primary Key value");
            }
        }
コード例 #4
0
        public async Task PopulateVMAsync(CheckingDeposit deposit)
        {
            this.model             = deposit;
            this.accountModel      = deposit.checkingAccount;
            this.ItemId            = this.model.id;
            this.ItemType          = AccountItemType.Deposits;
            this.ItemAmount        = model.transactionAmount;
            this.EndingBalance     = model.endingBalance;
            this.ItemDescription   = model.description;
            this.Description       = this.model.description;
            this.TransactionDate   = deposit.transactionDate > DateTime.MinValue ? deposit.transactionDate : DateTime.Now;
            this.ItemDate          = this.TransactionDate;
            this.TransactionAmount = model.transactionAmount;
            this.ObjectColorCode   = this.model.ColorCode;
            this.BudgetItemId      = model.budgetIncomeId;

            //await LoadBudgetData();
        }
コード例 #5
0
        async Task <CheckingDepositViewModel> AddCheckingDepositAsync()
        {
            CheckingDepositViewModel vm = new CheckingDepositViewModel(this.dbFilePath);

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

            CheckingDeposit deposit = new CheckingDeposit();

            deposit.checkingAccount   = model as CheckingAccount;
            deposit.checkingAccountId = model.id;

            await vm.PopulateVMAsync(deposit);

            return(vm);
        }
コード例 #6
0
        public async Task <CheckingDeposit> AddCheckingDepositAsync(CheckingDeposit deposit)
        {
            if (!context.CheckingDeposit.Any(d => d.id == deposit.id))
            {
                await Task.Run(() => context.CheckingDeposit.Add(deposit));

                await Task.Run(() => context.Entry(deposit).State = Microsoft.EntityFrameworkCore.EntityState.Added);

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

                if (deposit.budgetIncome != null)
                {
                    await Task.Run(() => context.Entry(deposit.budgetIncome).State = Microsoft.EntityFrameworkCore.EntityState.Unchanged);
                }
            }
            else
            {
                throw new Exception("A deposit record already exists with the same Primary Key value");
            }
            return(deposit);
        }
コード例 #7
0
 public void Put(int id, [FromBody] CheckingDeposit item)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
 public async Task UpdateCheckingDepositAsync(CheckingDeposit deposit)
 {
     var updated = await connection.UpdateAsync(deposit);
 }
コード例 #9
0
        public async Task <CheckingDeposit> GetCheckingDepositAsync(int id)
        {
            CheckingDeposit deposit = await connection.FindAsync <CheckingDeposit>(id);

            return(deposit);
        }
コード例 #10
0
 public async Task DeleteCheckingDepositAsync(CheckingDeposit deposit)
 {
     var deleted = await connection.DeleteAsync(deposit);
 }