Beispiel #1
0
 public AdminController(IUsersService usersService, IDepositsService depositService, ICreditsService creditService, IWalletsService walletsService, IChargeAccountsService chargeAccountService, IDebitCardsService debitCardService, ISupportTicketsService supportTicketService)
 {
     _userService          = usersService;
     _creditService        = creditService;
     _walletService        = walletsService;
     _depositService       = depositService;
     _chargeAccountService = chargeAccountService;
     _debitCardService     = debitCardService;
     _supportTicketService = supportTicketService;
 }
Beispiel #2
0
 public DebitCardsController(IDebitCardsService debitCardsService,
                             ICustomerService customerService,
                             UserManager <AppUser> userManager,
                             IActionResultMapper <DebitCardsController> actionResultMapper)
 {
     _debitCardsService  = debitCardsService;
     _customerService    = customerService;
     _userManager        = userManager;
     _actionResultMapper = actionResultMapper;
 }
Beispiel #3
0
 public CashTransactionsController(ICashTransactionsService cashTransactionsService,
                                   ICustomerService customerService,
                                   ICreditCardsService creditCardsService,
                                   IDebitCardsService debitCardsService,
                                   UserManager <AppUser> userManager,
                                   IActionResultMapper <CashTransactionsController> actionResultMapper)
 {
     _cashTransactionsService = cashTransactionsService;
     _customerService         = customerService;
     _creditCardsService      = creditCardsService;
     _debitCardsService       = debitCardsService;
     _userManager             = userManager;
     _actionResultMapper      = actionResultMapper;
 }
Beispiel #4
0
        // private readonly ITransactionService _transactionService;

        public ChargeAccountsController(IChargeAccountsService bankAccountService, IDebitCardsService debitCardService)
        {
            _chargeAccService = bankAccountService;
            _debitCardService = debitCardService;
        }
Beispiel #5
0
        //private readonly ITransactionService _transactionService;

        public DebitCardsController(IDebitCardsService debitCardService, IChargeAccountsService bankaccService /*ITransactionService transactionService*/)
        {
            _debitCardService     = debitCardService;
            _chargeAccountService = bankaccService;
            // _transactionService = transactionService;
        }
Beispiel #6
0
        public async Task <ActionResult <MessageModel> > CreateChargeAccount(ClaimsPrincipal currentUser, ChargeAccountRequestModel requestModel, IDebitCardsService _debitCardService)
        {
            string               role      = "";
            var                  username  = requestModel.Username;
            ChargeAccount        chargeAcc = requestModel.ChargeAccount;
            BCryptPasswordHasher _BCrypt   = new BCryptPasswordHasher();

            if (currentUser.HasClaim(c => c.Type == "Roles"))
            {
                string userRole = currentUser.Claims.FirstOrDefault(currentUser => currentUser.Type == "Roles").Value;
                role = userRole;
            }

            if (role == "Admin")
            {
                var userAuthenticate = await dbContext.Users.FirstOrDefaultAsync(x => x.Username == username);

                if (userAuthenticate != null)
                {
                    if (dbContext.ChargeAccounts.Where(x => x.UserId == userAuthenticate.Id).Count() < 10)
                    {
                        try
                        {
                            if (ValidateUser(userAuthenticate) && ValidateChargeAccount(chargeAcc))
                            {
                                chargeAcc.UserId = userAuthenticate.Id;
                                chargeAcc.Iban   = IBANGenerator.GenerateIBANInVitoshaBank("ChargeAccount", dbContext);
                                await dbContext.AddAsync(chargeAcc);

                                await dbContext.SaveChangesAsync();


                                Card card = new Card();
                                await _debitCardService.CreateDebitCard(currentUser, username, chargeAcc, card);

                                SendEmail(userAuthenticate.Email, _config);
                                responseModel.Message = "Charge Account created succesfully";
                                return(StatusCode(201, responseModel));
                            }
                            else if (ValidateUser(userAuthenticate) == false)
                            {
                                responseModel.Message = "User not found!";
                                return(StatusCode(404, responseModel));
                            }
                            else if (ValidateChargeAccount(chargeAcc) == false)
                            {
                                responseModel.Message = "Invalid parameteres!";
                                return(StatusCode(400, responseModel));
                            }
                        }
                        catch (NullReferenceException)
                        {
                            responseModel.Message = "Invalid parameteres!";
                            return(StatusCode(400, responseModel));
                        }
                    }

                    responseModel.Message = "User already has 10 Charge Accounts!";
                    return(StatusCode(400, responseModel));
                }
                else
                {
                    responseModel.Message = "User not found!";
                    return(StatusCode(404, responseModel));
                }
            }
            else
            {
                responseModel.Message = "You are not authorized to do such actions";
                return(StatusCode(403, responseModel));
            }
        }