Exemple #1
0
        public async Task <Guid> CreateNewExpense(ExpenseRequestDTO requestDTO)
        {
            var bankAccount = await _repository.GetByIdAsync <Domain.Model.Account.BankAccount>(requestDTO.BankAccountId);

            var institution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(requestDTO.InstitutionId);

            var sector = await _repository.GetByIdAsync <Domain.Model.Sector.Sector>(requestDTO.SectorId);

            if (bankAccount == null || institution == null || sector == null)
            {
                return(Guid.Empty);
            }

            var newInstance = new Domain.Model.Income.Expenses
            {
                Amount         = requestDTO.Amount,
                CurrencyType   = requestDTO.CurrencyType,
                Description    = requestDTO.Description,
                DocumentNumber = requestDTO.DocumentNumber,
                Expiry         = requestDTO.Expiry,
                ExpiryDate     = requestDTO.ExpiryDate,
                Type           = requestDTO.ExpenseType,
                BankAccount    = bankAccount,
                Institution    = institution,
                Sector         = sector
            };

            _repository.Add(newInstance);
            await _repository.CommitAsync();

            return(newInstance.Id);
        }
Exemple #2
0
        public async Task <Guid> UpdateAsync(Guid Id, InstitutionRequestDTO requestDTO)
        {
            var institution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(Id);

            if (institution == null)
            {
                return(Guid.Empty);
            }
            institution.Code         = requestDTO.Code;
            institution.EmailAddress = requestDTO.EmailAddress;
            institution.PhoneNumber  = requestDTO.PhoneNumber;
            institution.Name         = requestDTO.Name;
            institution.Status       = requestDTO.Status;
            _repository.Update(institution);
            await _repository.CommitAsync();

            return(Id);
        }
Exemple #3
0
        public async Task <Guid> CreateNewBankAccountAsync(BankAccountRequestDTO requestDTO)
        {
            Domain.Model.Institution.Institution currentInstitution;
            if (string.IsNullOrEmpty(CurrentInstitutionId))
            {//admin user so , ins id will come from request payload.
                currentInstitution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(requestDTO.InstitutionId.Value);
            }
            else
            {//casual user.
                currentInstitution = await _repository.GetByIdAsync <Domain.Model.Institution.Institution>(Guid.Parse(CurrentInstitutionId));
            }

            if (currentInstitution == null)
            {
                return(Guid.Empty);
            }

            var newInstance = new Domain.Model.Account.BankAccount
            {
                BankAccountName        = requestDTO.BankAccountName,
                Institution            = currentInstitution,
                AccountIBAN            = requestDTO.AccountIBAN,
                AccountNo              = requestDTO.AccountNo,
                AccountType            = requestDTO.AccountType,
                BankAccountDescription = requestDTO.BankAccountDescription,
                BankType       = requestDTO.BankType,
                BlockedBalance = requestDTO.BlockedBalance,
                CurrencyType   = requestDTO.CurrencyType,
                TotalBalance   = requestDTO.TotalBalance,
                UsableBalance  = requestDTO.UsableBalance
            };

            _repository.Add(newInstance);
            await _repository.CommitAsync();

            return(newInstance.Id);
        }