public async Task <IResponse> DeleteTransactionCategoryAsync(int transactionCategoryID)
        {
            var response = new Response();

            try
            {
                var transactionCategoryFromDB = await TransactionCategoryRepository.GetSingleTransactionCategoryByIDAsync(transactionCategoryID);

                if (transactionCategoryFromDB == null)
                {
                    response.Message = ResponseMessageDisplay.NotFound;
                    // Throw exception if duplicate existed
                    throw new FamilyHubException(string.Format(TransactionMessageDisplay.TransactionCategoryNotFoundMessage));
                }
                else
                {
                    await TransactionCategoryRepository.DeleteTransactionCategoryAsync(transactionCategoryFromDB);

                    response.Message = ResponseMessageDisplay.Success;
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
        public async Task <ISingleResponse <vmTransactionPrepareRequest> > PrepareTransactionRelatedRequestAsync(int currentUid)
        {
            var response = new SingleResponse <vmTransactionPrepareRequest>();

            try
            {
                // Retrieve PaymentMethods list
                response.Model.PaymentMethods = await PaymentMethodRepository.GetListPaymentMethodAsync();

                // Retrieve PaymentPayors list
                response.Model.PaymentPayors = await PaymentPayorRepository.GetListPaymentPayorAsync(currentUid);

                // Retrieve TransactionCategorys list
                response.Model.TransactionCategorys = await TransactionCategoryRepository.GetListTransactionCategoryAsync();

                // Retrieve TransactionTypes list
                response.Model.TransactionTypes = await TransactionTypeRepository.GetListTransactionTypeAsync();
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
Example #3
0
        private void Setup_Repository_FakeDbContext(List <TransactionCategory> fakeTransactionCategoryList)
        {
            // setup dbContext
            Setup_FakeDbContext(fakeTransactionCategoryList);

            // set up repository
            _repository = new TransactionCategoryRepository(_fakeDbContext);
        }
Example #4
0
        public void SetUp()
        {
            // setup fake model
            _dbTransactionCategory = new TransactionCategory {
                Id = 1, Name = "a", IsActive = true
            };

            // setup DbContext
            Setup_FakeDbContext();

            // set up repository
            _repository = new TransactionCategoryRepository(_fakeDbContext);
        }
Example #5
0
 private void SetRepositories()
 {
     AssetSettings                = new AssetSettingRepository(_context);
     AssetRelationships           = new AssetRelationshipRepository(_context);
     Assets                       = new AssetRepository(_context);
     AssetTransactions            = new AssetTransactionRepository(_context);
     AssetTypeSettingTypes        = new AssetTypeSettingTypeRepository(_context);
     AssetTypeRelationshipTypes   = new AssetTypeRelationshipTypeRepository(_context);
     AssetTypes                   = new AssetTypeRepository(_context);
     ParentChildRelationshipTypes = new ParentChildRelationshipTypeRepository(_context);
     RelationshipTypes            = new RelationshipTypeRepository(_context);
     SettingTypes                 = new SettingTypeRepository(_context);
     TransactionCategories        = new TransactionCategoryRepository(_context);
     TransactionDescriptions      = new TransactionDescriptionRepository(_context);
     TransactionTypes             = new TransactionTypeRepository(_context);
 }
        public async Task <IListResponse <vmTransactionCategoryList> > GetListTransactionCategoryAsync()
        {
            var response = new ListResponse <vmTransactionCategoryList>();

            try
            {
                var listTransactionCategoryFromDb = await TransactionCategoryRepository.GetListTransactionCategoryAsync();

                response.Model   = _mapper.Map <IEnumerable <TransactionCategory>, IEnumerable <vmTransactionCategoryList> >(listTransactionCategoryFromDb);
                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
        public async Task <IResponse> AddTransactionCategoryAsync(vmTransactionCategoryCreateRequest newTransactionCategoryRequest)
        {
            var response = new Response();

            try
            {
                var newTransactionCategory = _mapper.Map <vmTransactionCategoryCreateRequest, TransactionCategory>(newTransactionCategoryRequest);
                // Create new payment payor
                await TransactionCategoryRepository.AddTransactionCategoryAsync(newTransactionCategory);

                response.Message = ResponseMessageDisplay.Success;
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }
        public async Task <IResponse> UpdateTransactionCategoryAsync(int transactionCategoryID, vmTransactionCategoryUpdateRequest updateTransactionCategoryRequest)
        {
            var response = new Response();

            try
            {
                var duplicateTransactionCategory = await TransactionCategoryRepository.GetSingleTransactionCategoryByNameAsync(updateTransactionCategoryRequest.TransactionCategoryName);

                if (duplicateTransactionCategory != null && duplicateTransactionCategory.TransactionCategoryID != transactionCategoryID)
                {
                    response.Message = ResponseMessageDisplay.Duplicate;
                    // Throw exception if duplicate existed
                    throw new FamilyHubException(string.Format(TransactionMessageDisplay.TransactionCategoryAlreadyExistedMessage, updateTransactionCategoryRequest.TransactionCategoryName));
                }
                else
                {
                    var TransactionCategoryFromDB = await TransactionCategoryRepository.GetSingleTransactionCategoryByIDAsync(transactionCategoryID);

                    if (TransactionCategoryFromDB == null)
                    {
                        response.Message = ResponseMessageDisplay.NotFound;
                        // Throw exception if duplicate existed
                        throw new FamilyHubException(string.Format(TransactionMessageDisplay.TransactionCategoryNotFoundMessage));
                    }
                    else
                    {
                        _mapper.Map <vmTransactionCategoryUpdateRequest, TransactionCategory>(updateTransactionCategoryRequest, TransactionCategoryFromDB);
                        await TransactionCategoryRepository.UpdateTransactionCategoryAsync(TransactionCategoryFromDB);

                        response.Message = ResponseMessageDisplay.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }

            return(response);
        }