public static void Register(HttpConfiguration config)
        {
            //// Web API configuration and services
            var container = new UnityContainer();

            RegisterDataServices.Register(container);
            RegisterMappers.Register(container);
            RegisterServices.Register(container);
            RegisterFacades.Register(container);
            config.DependencyResolver = new UnityResolver(container);

            config.AddApiVersioning(v => v.AssumeDefaultVersionWhenUnspecified = true);

            // Web API routes
            var constraintResolver = new DefaultInlineConstraintResolver()
            {
                ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) }
            };

            // Web API routes
            config.MapHttpAttributeRoutes(constraintResolver);

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <SaespContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            RegisterServices.Resolver(services);

            services.AddMvc();
        }
        //public static IConfiguration StaticConfiguration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("AllowOrigin", c => c.AllowAnyOrigin());
            });

            services.AddControllers().AddNewtonsoftJson(
                options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(o =>
                          o.TokenValidationParameters = new TokenValidationParameters()
            {
                ValidateIssuer           = AppConfiguration.Token_ValidateIssuer,
                ValidateAudience         = AppConfiguration.Token_ValidateAudience,
                ValidateLifetime         = AppConfiguration.Token_ValidateLifetime,
                ValidateIssuerSigningKey = AppConfiguration.Token_ValidateIssuerSigningKey,
                IssuerSigningKey         =
                    new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AppConfiguration.TokenSecretKey)),
                ClockSkew = TimeSpan.Zero
            });

            services.AddAuthorization(options =>
            {
                options.AddPolicy(AppConfiguration.GeneralAccessPolicyName,
                                  policy => policy.Requirements.Add(new GeneralAccessRequirement()));
            });

            RegisterServices.Register(services);
        }
Esempio n. 4
0
        public ActionResult DeleteRegister(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Invalid_Selection;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new RegisterServices().DeleteRegister(id);
                if (k)
                {
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Delete_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Delete_Failure;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 5;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 5
0
        public ActionResult Register([FromBody] RegisterModel request)
        {
            UserModelOutput userModelOutput = new UserModelOutput();

            DisplayUser displayUser = new DisplayUser();

            try
            {
                var query      = new List <UserModel>((List <UserModel>)displayUser.DisplayAll()).AsQueryable();
                var CheckEmail = query.Where(p => p.user_email.StartsWith(request.user_email ?? String.Empty, StringComparison.InvariantCultureIgnoreCase));

                if (CheckEmail.Count() > 0)
                {
                    ModelState.AddModelError("Email", "Email already exists");
                }

                if (ModelState.IsValid)
                {
                    _logger.Information("Post Register");
                    RegisterServices _register = new RegisterServices();
                    var saving = _register.Add(request);

                    if (saving.Result == 1)
                    {
                        userModelOutput.IsSuccess = true;
                        userModelOutput.Code      = 200;
                        userModelOutput.Message   = "Success Register";
                    }
                }
                else
                {
                    _logger.Error("Failed Register");
                    string errordetails = "";
                    var    errors       = new List <string>();
                    foreach (var state in ModelState)
                    {
                        foreach (var error in state.Value.Errors)
                        {
                            string p = error.ErrorMessage;
                            errordetails = errordetails + error.ErrorMessage;
                        }
                    }

                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    dict.Add("error", errordetails);
                    userModelOutput.IsSuccess   = false;
                    userModelOutput.Code        = 422;
                    userModelOutput.Message     = "Failed Register";
                    userModelOutput.CustomField = dict;
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Failed Register" + ex.Message.ToString());
                userModelOutput.IsSuccess = false;
                userModelOutput.Code      = 422;
                userModelOutput.Message   = ex.Message.ToString();
            }
            return(Ok(userModelOutput));
        }
Esempio n. 6
0
        public ActionResult Register(RegisterModels model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    IRegisterServices registerService = new RegisterServices();
                    if (registerService.IsUsernameExist(model))
                    {
                        ModelState.AddModelError("", ErrorMessages.UsernameTaken);
                        return(View(model));
                    }

                    IEncryptionHelper encyptionHelper = new EncryptionHelper();
                    model.Password = encyptionHelper.EncryptString(model.Password, EncryptionTypeEnums.Member);

                    if (registerService.Register(model))
                    {
                        return(RedirectToAction("Login", "Account"));
                    }
                }

                return(View(model));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(StaticKeyHelper.WebApplication, StaticKeyHelper.Register, ex.Message);
                ModelState.AddModelError("", ErrorMessages.TechnicalIssues);
                return(RedirectToAction("Login", "Account"));
            }
        }
Esempio n. 7
0
        public ActionResult EditRegister(RegisterObject register)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateRegister(register);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_register"] == null)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldRegister = Session["_register"] as RegisterObject;
                    if (oldRegister == null || oldRegister.RegisterId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldRegister.Name = register.Name.Trim();
                    //todo: OutletId should be dynamic
                    oldRegister.CurrentOutletId = register.CurrentOutletId;

                    var k = new RegisterServices().UpdateRegister(oldRegister);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Model_State_Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 8
0
        public void BasicSetUp()
        {
            DaoFactory.Instance.ConnectionStringBuilder = null;
            RegisterDaoMocks.RegisterAll();
            RegisterServices.RegisterAll();

            this.Service = ServiceFactory.Instance.GetService <TService>();
        }
Esempio n. 9
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     AddCors(services);
     AddControllers(services);
     AddAuthentication(services);
     AddAuthorization(services);
     RegisterServices.Register(services);
 }
Esempio n. 10
0
        /// <summary>
        /// register/inject all the dependencies
        /// </summary>
        /// <param name="services">Collection of Services provided in the stratup</param>
        /// <param name="connectionString"> A Connection String to the DB, required to create ApplicationDBContext</param>
        public static void RegisterAllDependencies(this IServiceCollection services, string connectionString)
        {
            //Adding ApplicationDbContext before everything else
            services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(connectionString));

            RegisterRepositories.Register(services);
            RegisterServices.Register(services);
        }
Esempio n. 11
0
 static void Main()
 {
     using (var container = RegisterServices.Create())
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(container.Resolve <MainForm>());
     }
 }
 public void BlazorBreakdanceTestBase_Setup_CreatesTestContext_ConflictingServices()
 {
     BUnitTestContext.Should().NotBeNull();
     RegisterServices.Should().NotBeNull();
     BUnitTestContext.Services.Should().HaveCount(14);
     GetService <NavigationManager>().Should().NotBeNull().And.BeOfType(typeof(FakeNavigationManager));
     GetServices <NavigationManager>().Should().HaveCount(1);
     GetService <TestableNavigationManager>().Should().NotBeNull();
 }
Esempio n. 13
0
        public override async Task ExecuteCommandAsync(VsProject result)
        {
            try
            {
                var registrationSourceCode = await RegisterServices.GetRegistrationClassAsync(result);

                if (registrationSourceCode == null)
                {
                    throw new CodeFactoryException("Could load or create the dependency injection code.");
                }

                if (!registrationSourceCode.IsLoaded)
                {
                    throw new CodeFactoryException("Could load or create the dependency injection code.");
                }

                var registrationClasses = await DependencyInjectionManagement.LoadInstanceProjectClassesForRegistrationAsync(result);

                var manager = registrationSourceCode.LoadNamespaceManager(result.DefaultNamespace);

                var injectionMethod = DependencyInjectionManagement.BuildInjectionMethod(registrationClasses, false,
                                                                                         true, RegisterServices.TransientClassRegistrationMethodName,
                                                                                         RegisterServices.ServiceCollectionParameterName, manager);

                if (injectionMethod == null)
                {
                    throw new CodeFactoryException("Could not generated the automated dependency injection method");
                }

                var registrationClass =
                    registrationSourceCode.Classes.FirstOrDefault(c =>
                                                                  c.Name == RegisterServices.RegistrationClassName);

                if (registrationClass == null)
                {
                    throw new CodeFactoryException("Could not load the dependency injection class");
                }

                var autoRegistrationMethod = registrationClass.Methods.FirstOrDefault(m =>
                                                                                      m.Name == RegisterServices.TransientClassRegistrationMethodName);

                if (autoRegistrationMethod != null)
                {
                    await autoRegistrationMethod.ReplaceAsync(injectionMethod);
                }
                else
                {
                    await registrationClass.AddToEndAsync(injectionMethod);
                }
            }
            catch (Exception unhandledError)
            {
                _logger.Error($"The following unhandled error occurred while executing the solution explorer project command {commandTitle}. ",
                              unhandledError);
            }
        }
Esempio n. 14
0
        public ActionResult GetRegisterObjects(JQueryDataTableParamModel param)
        {
            var gVal = new GenericValidator();

            try
            {
                IEnumerable <RegisterObject> filteredRegisterObjects;
                var countG = new RegisterServices().GetObjectCount();

                var pagedRegisterObjects = GetRegisters(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredRegisterObjects = new RegisterServices().Search(param.sSearch);
                }
                else
                {
                    filteredRegisterObjects = pagedRegisterObjects;
                }

                if (!filteredRegisterObjects.Any())
                {
                    return(Json(new List <RegisterObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <RegisterObject, string> orderingFunction = (c => sortColumnIndex == 1 ?  c.Name: c.OutletName
                                                                  );

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredRegisterObjects = sortDirection == "asc" ? filteredRegisterObjects.OrderBy(orderingFunction) : filteredRegisterObjects.OrderByDescending(orderingFunction);

                var displayedUserProfilenels = filteredRegisterObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.RegisterId), c.Name, c.OutletName };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredRegisterObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <RegisterObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RegisterOptions.Register(services, Configuration);

            var provider = services.BuildServiceProvider();

            var dataBaseOption = provider.GetService <IOptions <DatabaseOption> >().Value;

            RegisterServices.Register(services, dataBaseOption);

            RegisterMappers.Register(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Esempio n. 16
0
        public static async Task Main()
        {
            SayHello();

            RegisterServices.Register();

            var worker = new TicketQueueWorker();

            await worker.RunAsync();


            Console.WriteLine("Enter any Key to exit");
            Console.ReadKey();
        }
Esempio n. 17
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // llamada al inyector
            RegisterServices.Register(services);
            RegisterHelperServices.Register(services);
        }
Esempio n. 18
0
        public Startup(IConfiguration configuration)
        {
            this.Configuration = configuration;

            string connectionString = this.Configuration.GetConnectionString("TestPrimitive");

            DaoFactory.Instance.ConnectionStringBuilder = new ConnectionStringBuilder(connectionString, typeof(SqliteContext))
            {
                SqlDialectType = typeof(SQLiteDialect), SqlDialectVersionType = typeof(SQLiteDialectVersion)
            };

            RegisterDaos.RegisterAll(DaoFactory.Instance.ConnectionStringBuilder.SqlDialectType, DaoFactory.Instance.ConnectionStringBuilder.SqlDialectVersionType);
            RegisterServices.RegisterAll();

            //this.RegisterView();
        }
Esempio n. 19
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            string connectionString = ConfigurationManager.ConnectionStrings["Test1225"].ConnectionString;

            DaoFactory.Instance.ConnectionStringBuilder = new ConnectionStringBuilder(connectionString, typeof(SqlContext))
            {
                SqlDialectType = typeof(SqlServerDialect), SqlDialectVersionType = typeof(SqlServerDialectVersion)
            };

            RegisterDaos.RegisterAll(DaoFactory.Instance.ConnectionStringBuilder.SqlDialectType, DaoFactory.Instance.ConnectionStringBuilder.SqlDialectVersionType);
            RegisterServices.RegisterAll();

            //var format = GlobalConfiguration.Configuration.Formatters;
            //format.XmlFormatter.SupportedMediaTypes.Clear();
        }
Esempio n. 20
0
        public Startup(IConfiguration configuration)
        {
            this.Configuration = configuration;

            string connectionString = this.Configuration.GetConnectionString("Products");

            DaoFactory.Instance.ConnectionStringBuilder = new ConnectionStringBuilder(connectionString, typeof(SqlContext))
            {
                SqlDialectType = typeof(SqlServerDialect), SqlDialectVersionType = typeof(SqlServerDialectVersion)
            };

            RegisterDaos.RegisterAll(DaoFactory.Instance.ConnectionStringBuilder.SqlDialectType, DaoFactory.Instance.ConnectionStringBuilder.SqlDialectVersionType);
            RegisterServices.RegisterAll();
            /*add customized code between this region*/
            /*add customized code between this region*/
            //this.RegisterView();
        }
        public void BlazorBreakdanceTestBase_TestSetup_CreatesTestContext_Services()
        {
            //RWM: We're not *quite* setting this up properly, because we want to test the state both before and after calling TestSetup();
            TestHost.Should().BeNull();
            BUnitTestContext.Should().BeNull();
            RegisterServices.Should().BeNull();

            RegisterServices = services => {
                services.AddScoped <NavigationManager>(sp => new TestableNavigationManager());
            };
            TestSetup();

            TestHost.Should().NotBeNull();
            BUnitTestContext.Should().NotBeNull();
            RegisterServices.Should().NotBeNull();
            BUnitTestContext.Services.Should().HaveCount(14);
            GetService <NavigationManager>().Should().NotBeNull().And.BeOfType(typeof(TestableNavigationManager));
            GetServices <NavigationManager>().Should().HaveCount(2);
        }
Esempio n. 22
0
        protected void Application_Start()
        {
            Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(AreaRegistration))).OrderByDescending(r => GetAreaLevelNumber(r.FullName)).ToList().ForEach(r => RegisterArea(r, RouteTable.Routes, null));
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            string connectionString = ConfigurationManager.ConnectionStrings["Deli"].ConnectionString;

            DaoFactory.Instance.ConnectionStringBuilder = new ConnectionStringBuilder(connectionString, typeof(SqlContext))
            {
                SqlDialectType = typeof(SqlServerDialect), SqlDialectVersionType = typeof(SqlServerDialectVersion)
            };

            RegisterDaos.RegisterAll(DaoFactory.Instance.ConnectionStringBuilder.SqlDialectType, DaoFactory.Instance.ConnectionStringBuilder.SqlDialectVersionType);
            RegisterServices.RegisterAll();/*add customized code between this region*/
            /*add customized code between this region*/
            this.RegisterView();
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            Log.Logger.Information("Startup");

            RegisterServices.Register(Container);

            HostFactory.Run(x =>
            {
                x.UseSimpleInjector(Container);

                x.Service <MainService>(s =>
                {
                    s.ConstructUsingSimpleInjector();
                    s.WhenStarted(p => p.Start());
                    s.WhenStopped(p => p.Stop());
                });
                x.RunAsNetworkService();

                x.StartAutomatically();
                x.UseSerilog(Log.Logger);
                x.EnableServiceRecovery(r =>
                {
                    r.RestartService(0);
                    r.RestartService(1);
                    r.RestartService(2);
                    r.OnCrashOnly();
                    r.SetResetPeriod(1);
                });

                x.SetDescription("A proxy for the TvHeadEnd M3u files");
                x.SetDisplayName("TvHeadEndM3uProxy");
                x.SetServiceName("TvHeadEndM3uProxy");
            });

            Container.Dispose();
            Log.CloseAndFlush();
        }
Esempio n. 24
0
        public ActionResult AddRegister(RegisterObject register)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateRegister(register);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new RegisterServices().AddRegister(register);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 25
0
        public ActionResult GetRegister(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new RegisterObject(), JsonRequestBehavior.AllowGet));
                }

                var register = new RegisterServices().GetRegister(id);
                if (id < 1)
                {
                    return(Json(new RegisterObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_register"] = register;
                return(Json(register, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new RegisterObject(), JsonRequestBehavior.AllowGet));
            }
        }
        public void BlazorBreakdanceTestBase_Setup_CreatesTestContext_NoServices()
        {
            //RWM: We're not *quite* setting this up properly, because we want to test the state both before and after calling TestSetup();
            TestHost.Should().BeNull();
            BUnitTestContext.Should().BeNull();
            RegisterServices.Should().BeNull();
            GetService <IConfiguration>().Should().BeNull();

            TestSetup();

            TestHost.Should().NotBeNull();
            BUnitTestContext.Should().NotBeNull();
            RegisterServices.Should().BeNull();
#if NET6_0_OR_GREATER
            TestHost.Services.GetAllServiceDescriptors().Should().HaveCount(33);
#endif
#if NET5_0
            TestHost.Services.GetAllServiceDescriptors().Should().HaveCount(32);
#endif
            BUnitTestContext.Services.Should().HaveCount(13);
            GetService <NavigationManager>().Should().NotBeNull().And.BeOfType(typeof(FakeNavigationManager));
            BUnitTestContext.Services.GetService <IConfiguration>().Should().NotBeNull();
        }
        public void BlazorBreakdanceTestBase_GetServices_ReturnsServiceOnlyInTestContext()
        {
            //RWM: We're not *quite* setting this up properly, because we want to test the state both before and after calling TestSetup();
            TestHost.Should().BeNull();
            BUnitTestContext.Should().BeNull();
            RegisterServices.Should().BeNull();

            TestHostBuilder.ConfigureServices((context, services) => services.AddSingleton <DummyService>());
            TestSetup();

            TestHost.Should().NotBeNull();
            BUnitTestContext.Should().NotBeNull();
            RegisterServices.Should().BeNull();
            BUnitTestContext.Services.Should().HaveCount(13);
            BUnitTestContext.Services.GetService <DummyService>().Should().BeNull();
#if NET6_0_OR_GREATER
            TestHost.Services.GetAllServiceDescriptors().Should().HaveCount(34);
#endif
#if NET5_0
            TestHost.Services.GetAllServiceDescriptors().Should().HaveCount(33);
#endif
            TestHost.Services.GetService <DummyService>().Should().NotBeNull();
            GetService <DummyService>().Should().NotBeNull();
        }
Esempio n. 28
0
        public async void Handle_Clicked(object sender, System.EventArgs e)
        {
            RegisterServices registerServices = new RegisterServices();

            UserModel newUser = new UserModel
            {
                firstname = FirstName.Text,
                lastname  = Surname.Text,
                email     = Email.Text,
                password  = Password.Text
            };

            var res = await registerServices.PostCustomer(newUser);

            successs.Text = res.ToString();
            if (res)
            {
                successs.Text = "Registration succeful";
            }
            else
            {
                successs.Text = res.ToString();
            }
        }
Esempio n. 29
0
 public void BasicTearDown()
 {
     RegisterServices.UnRegisterAll();
     RegisterDaoMocks.UnRegisterAll();
 }
Esempio n. 30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,

                    ValidIssuer      = "https://localhost:44308",
                    ValidAudience    = "https://localhost:44308",
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SystemConstants.JWT))
                };
            });
            services.AddMvc(option => option.EnableEndpointRouting = false).SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
            services.AddElmah();
            services.AddSignalR();
            services.AddElmah <ElmahCore.Sql.SqlErrorLog>(options =>
            {
                options.ConnectionString = Configuration.GetConnectionString("simbayuConn"); // DB structure see here: https://bitbucket.org/project-elmah/main/downloads/ELMAH-1.2-db-SQLServer.sql
            });
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.Configure <EmailSettings>(Configuration.GetSection("EmailSettings"));
            // Tenant Services
            // Classes to register
            TypesToRegister.ForEach(x => { if (x.DeclaringType == null)
                                           {
                                               services.AddScoped(x);
                                           }
                                    });
            RegisterRepos.registerReposDI(ref services, TypesToRegister);
            RegisterServices.registerServicesDI(ref services, TypesToRegister);
            //services.AddScopedDynamic<IProductService>(TypesToRegister);
            // Global Service provider
            services.AddScoped(typeof(IServicesProvider <>), typeof(ServicesProvider <>));
            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description =
                        "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"",
                    Name   = "Authorization",
                    In     = ParameterLocation.Header,
                    Type   = SecuritySchemeType.ApiKey,
                    Scheme = "Bearer"
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement()
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            },
                            Scheme = "oauth2",
                            Name   = "Bearer",
                            In     = ParameterLocation.Header,
                        },
                        new List <string>()
                    }
                });
                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }