Пример #1
0
        public int?CreateExpense(ExpenseServiceModel model)
        {
            var expense = new Expense
            {
                UserId         = model.UserId,
                ExpenseCaption = model.ExpenseCaption,
                Amount         = model.Amount
            };

            _expenseRepository.Add(expense);
            _expenseRepository.Complete();

            if (_expenseRepository.IsError)
            {
                throw new Exception(Resources.TextAbort);
            }

            return(expense.Id);
        }
Пример #2
0
        public void UpdateExpense(ExpenseServiceModel model)
        {
            var expense = _expenseRepository.GetByID(model.Id);

            if (expense == null)
            {
                throw new Exception(Resources.ValidationExpenseNotFound);
            }
            else
            {
                expense.ExpenseCaption = model.ExpenseCaption;
                expense.Amount         = model.Amount;

                _expenseRepository.Update(expense);
                _expenseRepository.Complete();

                if (_expenseRepository.IsError)
                {
                    throw new Exception(Resources.TextAbort);
                }
            }
        }