예제 #1
0
        public async Task AddExpense(ExpenseDto expense)
        {
            var entry = expense.ToEntry();

            _baseInfoContext.ExpenseInfos.Add(entry);
            await _baseInfoContext.SaveChangesAsync();

            expense.ExpenseId = entry.ExpenseId;
        }
예제 #2
0
        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();
        }