예제 #1
0
        public OnePayTest()
        {
            //Context preperation
            configuration = new ConfigurationBuilder()
                            .SetBasePath(Directory.GetCurrentDirectory())
                            .AddJsonFile("appSettings.json")
                            .Build();
            string connectionString = configuration.GetConnectionString("DefaultConnection");
            var    dbOptions        = new DbContextOptionsBuilder <OnePayContext>().UseSqlServer(connectionString).Options;

            onePayContext = new OnePayContext(dbOptions);

            //Initialize mapper
            var mappings = new MapperConfigurationExpression();

            mappings.AddProfile <AutoMapperProfile>();
            Mapper.Initialize(mappings);

            IUserService userService = new UserService(onePayContext);

            usersController = new UsersController(userService, Mapper.Instance);

            IAccountsService accountsService = new AccountsService(onePayContext);

            userAccountsController = new UserAccountsController(accountsService, userService, Mapper.Instance);

            IBusinessProductService businessProductService = new BusinessProductService(onePayContext);

            businessProductsController = new BusinessProductsController(businessProductService, userService, Mapper.Instance);

            ITransactionService transactionService = new TransactionService(onePayContext);

            onePayTransactionsController = new OnePayTransactionsController(transactionService, userService, Mapper.Instance);

            IOnePayService      onePayService      = new OnePayService(onePayContext, businessProductService, userService);
            IMessagingService   messagingService   = new MessagingService(onePayContext);
            ICoreBankingService coreBankingService = new CoreBankingService(onePayContext, userService, accountsService, businessProductService, messagingService, transactionService);

            onePayController = new OnePayController(transactionService, userService, onePayService, coreBankingService, Mapper.Instance);

            Startup.APIKEY = configuration["APIKEYs:TextLocal"];
            Startup.APIURL = configuration["APIURLs:TextLocalUrl"];
        }
예제 #2
0
 public void OnActionExecuting(ActionExecutingContext context)
 {
     if (context.ActionDescriptor.ActionName != nameof(UserAccountsController.Login) &&
         context.ActionDescriptor.ActionName != nameof(UserAccountsController.ChangePassword) &&
         context.ActionDescriptor.ActionName != nameof(LandingPageController.LandingPage) &&
         context.ActionDescriptor.ControllerDescriptor.ControllerName != ArticlesController.CONTROLLERNAME)
     {
         if (!UserAccountsController.isLoggedIn(context.HttpContext.Session))
         {
             context.Result = new RedirectToRouteResult(
                 new RouteValueDictionary(new
             {
                 action     = UserAccountsController.ACTIONNAME_Login,
                 controller = UserAccountsController.CONTROLLERNAME,
                 returnUrl  = context.HttpContext.Request.RawUrl
             })
                 );
         }
     }
 }
        public void Should_Insert()
        {
            IConfiguration         config = InitConfiguration();
            UserAccountsController userAccountsController = new UserAccountsController(config);

            UserLoginDto user = new UserLoginDto
            {
                Username = "******",
                Password = "******",
                Profile  = "Public"
            };

            var farfetchMessage = userAccountsController.Insert(user);

            Assert.NotNull(farfetchMessage);
            Assert.AreEqual(typeof(FarfetchMessage <UserLoginDto>), farfetchMessage.GetType());
            Assert.NotNull(farfetchMessage.Result);
            Assert.AreEqual(user.Username, farfetchMessage.Result.Username);
            Assert.AreEqual(user.Password, farfetchMessage.Result.Password);
            Assert.AreEqual(user.Profile, farfetchMessage.Result.Profile);
        }
예제 #4
0
 public override string GetUserId(Controller controller)
 {
     return(UserAccountsController.getUserId(controller.Session).ToString());
 }