Exemplo n.º 1
0
        public RegisterForm()
        {
            InitializeComponent();

            mapper  = AutoMapperProvider.GetIMapper();
            context = ContextProvider.GetApplicationContext();
            registrationValidator = new RegistrationModelValidator();
        }
Exemplo n.º 2
0
        public UserResultsForm(Guid userId)
        {
            InitializeComponent();

            mapper  = AutoMapperProvider.GetIMapper();
            context = ContextProvider.GetApplicationContext();

            FillUserResultsGrid(userId);
        }
Exemplo n.º 3
0
        public TimeResultForm(Guid testResultId)
        {
            mapper  = AutoMapperProvider.GetIMapper();
            context = ContextProvider.GetApplicationContext();

            InitializeComponent();

            SetFields(testResultId);
        }
Exemplo n.º 4
0
        public ResultsForm()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            mapper  = AutoMapperProvider.GetIMapper();
            context = ContextProvider.GetApplicationContext();

            FillUserResultsGrid(string.Empty);
        }
Exemplo n.º 5
0
        public AllTestForm()
        {
            InitializeComponent();

            mapper  = AutoMapperProvider.GetIMapper();
            context = ContextProvider.GetApplicationContext();

            SetItemsToTypeComboBox();
            SetItemsToTopicComboBox();
        }
Exemplo n.º 6
0
        public NewTestForm()
        {
            InitializeComponent();
            StartPosition         = FormStartPosition.CenterScreen;
            mapper                = AutoMapperProvider.GetIMapper();
            context               = ContextProvider.GetApplicationContext();
            newTestModelValidator = new NewTestModelValidator();

            SetItemsToTypeComboBox();
            SetItemsToTopicComboBox();
        }
Exemplo n.º 7
0
        public Main()
        {
            InitializeComponent();

            _mapper        = AutoMapperProvider.GetIMapper();
            _database      = ApplicationProvider.GetUnitOfWork();
            _clientService = ApplicationProvider.GetProxy();

            Show();
            //SetIcons();
            Configure();
        }
Exemplo n.º 8
0
        public void Map_Checkpoint_to_dto()
        {
            var id     = Guid.NewGuid();
            var mapper = new AutoMapperProvider();
            var dto    = mapper.Map <CheckpointDto>(new Checkpoint
            {
                Id    = id,
                Count = 5
            });

            dto.Id.Value.Should().Be(id);
            dto.Count.Should().Be(5);

            var cp = mapper.Map <Checkpoint>(dto);

            cp.Id.Value.Should().Be(id);
        }
Exemplo n.º 9
0
        public QwestForm(Guid testId, int stepNumber, int numberOfSteps)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;

            mapper      = AutoMapperProvider.GetIMapper();
            context     = ContextProvider.GetApplicationContext();
            this.testId = testId;

            this.Text = string.Format("Question #{0}/{1}", stepNumber, numberOfSteps);
            if (stepNumber == numberOfSteps)
            {
                ContinueButton.Text = "End";
            }

            quizModelValidator = new QuizModelValidator();
        }
Exemplo n.º 10
0
        public void MapTo_ReturnDto_WithEntity()
        {
            // Arrange
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Entity, Dto>();
            });
            var entity = GetEntity();
            AutoMapperProvider mapperProvider = new AutoMapperProvider(config);

            // Act
            var dto  = mapperProvider.MapTo <Dto>(entity);
            var dto2 = new Dto();

            dto2 = mapperProvider.MapTo(entity, dto2);

            // Assert
            Assert.True(dto.ValuesEqualTo(entity));
            Assert.True(entity.ValuesEqualTo(dto2));
        }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // services.TryAddScoped<StatisticListener>();


            // AppEvents.ApplicationStarting += (sender, serviceProvider) =>
            // {
            //     var listener = serviceProvider.GetService<StatisticListener>();
            //     AppEvents.Services = serviceProvider;
            //     listener.StartListening();
            // };

            // AppEvents.ApplicationStopping += (sender, serviceProvider) =>
            // {
            //     var listener = serviceProvider.GetService<StatisticListener>();
            //     listener.StopListening();
            // };

            services.TryAddSingleton <IAppSettings>(AppSettings);
            services.TryAddSingleton <AppEvents>(AppEvents);

            services.TryAddSingleton <Configuration>((s) =>
            {
                var configPath = HostingEnvironment.ContentRootFileProvider.GetFileInfo("our.orders.config");

                return(configPath.Exists ?
                       JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(configPath.PhysicalPath)) :
                       new Configuration());
            });

            services.TryAddSingleton <AutoMapperProvider>();

            services.TryAddSingleton <IEmailSender, LoggerSender>();

            var autoMapperProvider = new AutoMapperProvider(services);

            services.AddSingleton <Profile, AutoMapperProfile>();
            services.AddSingleton <IMapper>((s) => autoMapperProvider.GetMapper(s));

            services.AddMemoryCache();

            services.AddAntiforgery(options =>
            {
                options.Cookie.Name   = "XSRF-TOKEN";
                options.HeaderName    = "X-XSRF-TOKEN";
                options.FormFieldName = "requestVerificationToken";
            });


            // Appsettings services custom configuration
            AppEvents.OnConfigure(services);

            // ******  Services depending on AppSettings ******

            // AppSettings validation
            var appSettingsValidator = new AppSettingsValidator();

            appSettingsValidator.EnsureValid(AppSettings);


            var roleStore = new RoleStore();

            services.AddSingleton <RoleStore>(roleStore);
            services.AddSingleton <IRoleStore <Role> >(roleStore);


            services.AddTransient <IOrder, Order>();
            services.AddTransient <IProduct, Product>();
            services.AddTransient <IClient, Client>();
            services.AddTransient <ShippingTemplate>();
            services.AddTransient <DocumentTemplate>();
            services.AddTransient <Shop>();
            services.AddTransient <Movement>();
            services.AddTransient <Voucher>();
            services.AddTransient <StockUnit>();
            services.AddTransient <Warehouse>();
            services.AddTransient <Category>();
            services.AddTransient <User>();



            services.TryAddTransient <OrderService, OrderService>();
            services.TryAddTransient <IService <IOrder>, OrderService>();

            services.TryAddTransient <ProductService, ProductService>();
            services.TryAddTransient <IService <IProduct>, ProductService>();

            services.TryAddTransient <IService <IShippingTemplate>, Service <IShippingTemplate> >();
            services.TryAddTransient <IService <DocumentTemplate>, Service <DocumentTemplate> >();

            services.TryAddTransient <IService <IClient>, Service <IClient> >();

            services.TryAddTransient <IService <Shop>, Service <Shop> >();
            services.TryAddTransient <IService <Movement>, Service <Movement> >();
            services.TryAddTransient <IService <Voucher>, Service <Voucher> >();
            services.TryAddTransient <IService <StockUnit>, Service <StockUnit> >();
            services.TryAddTransient <IService <Warehouse>, Service <Warehouse> >();
            services.TryAddTransient <IService <Category>, Service <Category> >();


            var key = Encoding.ASCII.GetBytes(AppSettings.JwtSecret);

            // ******  End Services depending on AppSettings ******


            // configure jwt authentication

            services
            .AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            // .AddCookie(cfg => cfg.SlidingExpiration = true)
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata = false;
                //x.SaveToken = true;

                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };

                x.Events = new JwtBearerEvents
                {
                    // For debugging...
                    OnAuthenticationFailed = async(context) =>
                    {
                        await Task.FromResult(0);
                    },
                    OnChallenge = async(context) =>
                    {
                        await Task.FromResult(0);
                    },
                    OnMessageReceived = async(context) =>
                    {
                        await Task.FromResult(0);
                    },
                    OnTokenValidated = async(context) =>
                    {
                        await Task.FromResult(0);
                    }
                };
            });

            // Add framework services.
            services
            .AddMvc(options =>
            {
                // options.Conventions.Insert(0, new RoutePrefixConvention(new RouteAttribute("our-orders")));
                options.Filters.Add <OperationCancelledExceptionFilter>();
            })

            .AddJsonOptions(options =>
            {
                options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                options.SerializerSettings.ContractResolver  = new DefaultContractResolver();
                options.SerializerSettings.Formatting        = Formatting.Indented;
                options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());

                JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
                {
                    ContractResolver  = new DefaultContractResolver(),
                    Formatting        = Newtonsoft.Json.Formatting.Indented,
                    NullValueHandling = NullValueHandling.Ignore,
                    Converters        = new List <JsonConverter> {
                        new StringEnumConverter()
                    }
                };
            })
            .ConfigureApplicationPartManager(manager =>
            {
                manager.FeatureProviders.Add(new InternalControllerFeature());
                manager.FeatureProviders.Add(new ExternalControllerFeatureProvider(AppSettings));
            });
#if NETCORE2_2
            var embeddedProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(this.GetType()));
#else
            var embeddedProvider = new EmbeddedFileProvider(Assembly.GetAssembly(this.GetType()), "our.orders");
#endif
            services.AddSingleton <IFileProvider>(embeddedProvider);

            // configure DI for application services
            // services.AddScoped<IUserService, UserService>();
        }
Exemplo n.º 12
0
 public MemberMapperTests()
 {
     _mapper ??= AutoMapperProvider.Get();
 }
Exemplo n.º 13
0
 public VolunteerEmergencyContactController()
 {
     _ctx    = HttpContext.Current.GetOwinContext().Get <CrmServiceContext>();
     _mapper = AutoMapperProvider.GetMapper();
 }
Exemplo n.º 14
0
 public CommonMapperTests()
 {
     _mapper ??= AutoMapperProvider.Get();
 }
 private void DependencyInjectionSystem(IServiceCollection services)
 {
     services.AddScoped <IOops, Oops>();
     services.AddScoped <IDropDownList, DropDownList>();
     services.AddSingleton(cm => AutoMapperProvider.ConfigureAutoMapper());
 }
Exemplo n.º 16
0
 public RegionController()
 {
     _ctx    = HttpContext.Current.GetOwinContext().Get <CrmServiceContext>();
     _mapper = AutoMapperProvider.GetMapper();
 }
Exemplo n.º 17
0
 public VolunteerSelfIdentificationController()
 {
     _ctx    = HttpContext.Current.GetOwinContext().Get <CrmServiceContext>();
     _mapper = AutoMapperProvider.GetMapper();
 }
Exemplo n.º 18
0
 public AccountMapperTests()
 {
     _mapper ??= AutoMapperProvider.Get();
 }
Exemplo n.º 19
0
 public PortalUserStore(CrmServiceContext crmServiceContext)
 {
     _ctx    = crmServiceContext;
     _mapper = AutoMapperProvider.GetMapper();
 }
Exemplo n.º 20
0
 public LoginWindow()
 {
     InitializeComponent();
     _mapper        = AutoMapperProvider.GetIMapper();
     _clientService = ApplicationProvider.GetProxy();
 }