private async Task <bool> Save() { if (await _db.SaveChangesAsync() > 0) { return(true); } return(false); }
public async Task <int> ChargeWallet(string username, int price, string description, bool isDone = false) { var user = await _db.Users.FirstAsync(user => user.Username == username); var wallet = new Transaction() { UserId = user.UserId, TransactionTypeId = 1, Price = price, Description = description, IsDone = isDone, PaidDate = DateTime.Now }; await _db.Transactions.AddAsync(wallet); await _db.SaveChangesAsync(); return(wallet.TransactionId); }