Пример #1
0
 public int CreateBudgetDetail(beBudgetDetail budgetDetailEntity)
 {
     using (var scope = new TransactionScope())
     {
         var budgetDetail = new BudgetDetail
         {
             Id         = new int(),
             BudgetId   = budgetDetailEntity.BudgetId,
             Amount     = budgetDetailEntity.Amount,
             CategoryId = budgetDetailEntity.CategoryId,
             CreatedBy  = budgetDetailEntity.CreatedBy,
             CreatedOn  = DateTime.Now,
             ModifiedBy = budgetDetailEntity.ModifiedBy,
             ModifiedOn = budgetDetailEntity.ModifiedOn,
         };
         _unitOfWork.BudgetDetailRepository.Insert(budgetDetail);
         _unitOfWork.Save();
         scope.Complete();
         return(budgetDetail.Id);
     }
 }
Пример #2
0
        public bool UpdateBudgetDetail(int budgetDetailId, beBudgetDetail budgetDetailEntity)
        {
            var success = false;

            if (budgetDetailEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var budgetDetail = _unitOfWork.BudgetDetailRepository.GetById(budgetDetailId);
                    if (budgetDetail != null)
                    {
                        budgetDetail.CategoryId = budgetDetailEntity.CategoryId;
                        budgetDetail.Amount     = budgetDetailEntity.Amount;
                        _unitOfWork.BudgetDetailRepository.Update(budgetDetail);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }