コード例 #1
0
        public Task DeleteAsync(WalletPrivate model)
        {
            model.IsDeleted = true;

            _db.Update(model);
            return(_db.SaveChangesAsync());
        }
コード例 #2
0
        public Task <Account> CreateAsync(Account model)
        {
            model.CardHolder.Id        = _db.CardHolders.Count() > 0 ? _db.CardHolders.Last().Id + 1 : 1;
            model.CardHolder.IsDeleted = false;
            _db.CardHolders.Add(model.CardHolder);

            model.Id           = _db.Accounts.Count() > 0 ? _db.Accounts.Last().Id + 1 : 1;
            model.CardHolderId = model.CardHolder.Id;
            model.CreatedAt    = DateTime.UtcNow;
            model.IsDeleted    = false;
            _db.Accounts.Add(model);

            var wallet = new WalletPrivate
            {
                Id           = _db.Wallets.Count() > 0 ? _db.Wallets.Last().Id + 1 : 1,
                CardHolderId = model.CardHolderId,
                CardHolder   = model.CardHolder,
                CurrencyId   = 1,
                Currency     = _db.Currencies.First(x => x.Id == 1),
                Balance      = 0m,
                IsDeleted    = false
            };

            _db.Wallets.Add(wallet);
            model.CardHolder.Wallets = new Wallet[1] {
                wallet
            };

            return(Task.FromResult(model));
        }
コード例 #3
0
        public async Task <Account> CreateAsync(Account model)
        {
            model.CardHolder.IsDeleted = false;
            _db.CardHolders.Add(model.CardHolder);
            await _db.SaveChangesAsync();

            model.CardHolderId = model.CardHolder.Id;
            model.CreatedAt    = DateTime.UtcNow;
            model.IsDeleted    = false;
            _db.Accounts.Add(model);
            await _db.SaveChangesAsync();

            var wallet = new WalletPrivate
            {
                CardHolderId = model.CardHolderId,
                CardHolder   = model.CardHolder,
                CurrencyId   = 1,
                Currency     = _db.Currencies.First(x => x.Id == 1),
                Balance      = 0m,
                IsDeleted    = false
            };

            _db.Wallets.Add(wallet);
            await _db.SaveChangesAsync();

            model.CardHolder.Wallets = new Wallet[1] {
                wallet
            };

            return(model);
        }
コード例 #4
0
 public Task <WalletPrivate> CreateAsync(WalletPrivate model)
 {
     model.Id        = _db.Wallets.Count() > 0 ? _db.Accounts.Last().Id + 1 : 1;
     model.IsDeleted = false;
     _db.Wallets.Add(model);
     return(Task.FromResult(model));
 }
コード例 #5
0
        public async Task <WalletPrivate> CreateAsync(WalletPrivate model)
        {
            model.IsDeleted = false;
            _db.Wallets.Add(model);
            await _db.SaveChangesAsync();

            return(model);
        }
コード例 #6
0
        public async Task <WalletPrivate> UpdateAsync(WalletPrivate model)
        {
            var update = await _db.Wallets.FirstOrDefaultAsync(x => x.Id == model.Id);

            update.Balance = model.Balance;
            _db.Wallets.Update(model);
            await _db.SaveChangesAsync();

            return(update);
        }
コード例 #7
0
        public Task DeleteAsync(WalletPrivate model)
        {
            model.IsDeleted = true;

            return(Task.FromResult(0));
        }
コード例 #8
0
        public Task <WalletPrivate> UpdateAsync(WalletPrivate model)
        {
            var update = _db.Wallets.First(x => x.Id == model.Id);

            return(Task.FromResult(update));
        }