public Task DeleteAsync(WalletPrivate model) { model.IsDeleted = true; _db.Update(model); return(_db.SaveChangesAsync()); }
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)); }
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); }
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)); }
public async Task <WalletPrivate> CreateAsync(WalletPrivate model) { model.IsDeleted = false; _db.Wallets.Add(model); await _db.SaveChangesAsync(); return(model); }
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); }
public Task DeleteAsync(WalletPrivate model) { model.IsDeleted = true; return(Task.FromResult(0)); }
public Task <WalletPrivate> UpdateAsync(WalletPrivate model) { var update = _db.Wallets.First(x => x.Id == model.Id); return(Task.FromResult(update)); }