public async Task AddExpense(ExpenseDto expense) { var entry = expense.ToEntry(); _baseInfoContext.ExpenseInfos.Add(entry); await _baseInfoContext.SaveChangesAsync(); expense.ExpenseId = entry.ExpenseId; }
public async Task EditExpense(ExpenseDto expense) { if (!_baseInfoContext.ExpenseInfos.Any(c => c.ExpenseId == expense.ExpenseId)) { throw new NullReferenceException($"Cannot Find Expense with {expense.ExpenseId} id"); } var entry = expense.ToEntry(); _baseInfoContext.ExpenseInfos.Update(entry); await _baseInfoContext.SaveChangesAsync(); }