public bool UpdateBudget(int budgetId, beBudget budgetEntity) { var success = false; if (budgetEntity != null) { using (var scope = new TransactionScope()) { var budget = _unitOfWork.BudgetRepository.GetById(budgetId); if (budget != null) { budget.Month = budgetEntity.Month; budget.Year = budgetEntity.Year; _unitOfWork.BudgetRepository.Update(budget); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
public int CreateBudget(beBudget budgetEntity) { using (var scope = new TransactionScope()) { var budget = new Budget { Id = new int(), UserId = budgetEntity.UserId, Month = budgetEntity.Month, Year = budgetEntity.Year, IsRecuring = budgetEntity.IsRecuring, Type = budgetEntity.Type, CreatedBy = budgetEntity.CreatedBy, CreatedOn = DateTime.Now, ModifiedBy = budgetEntity.ModifiedBy, ModifiedOn = budgetEntity.ModifiedOn, }; _unitOfWork.BudgetRepository.Insert(budget); _unitOfWork.Save(); scope.Complete(); return(budget.Id); } }