Ejemplo n.º 1
0
        public LanguageStringService(IGenericRepository <Language> languaesGR,
                                     IGenericRepository <LanguageString> languageStringGR,
                                     IGenericRepository <LanguageStringType> languageStringTypeGR,
                                     IGenericRepository <LanguageStringIdType> languageStringIdTypeGR,
                                     IGenericRepository <LanguageStringId> languageStringIdGR,
                                     LanguageStringServiceConfiguration configuration,
                                     ScopedHttpContext scopedHttpContext)
        {
            _languaesGR             = languaesGR;
            _languageStringGR       = languageStringGR;
            _languageStringIdTypeGR = languageStringIdTypeGR;
            _languageStringTypeGR   = languageStringTypeGR;
            _languageStringIdGR     = languageStringIdGR;
            _configuration          = configuration;
            _httpContext            = scopedHttpContext.HttpContext;

            if (_httpContext.Request.Headers.ContainsKey("accept-language") && ((String)_httpContext.Request.Headers["accept-language"]).Length == 2)
            {
                _langAddName = _httpContext.Request.Headers["accept-language"];
            }

            if (_langAddName == null || _languaesGR.CountWhere(x => x.AbbName == _langAddName) == 0)
            {
                _langAddName = _configuration.DefaultLanguage;
            }


            /*foreach (var item in arguments)
             *  draftBody = draftBody.ReplaceFirstOccurrance("$arg$", item);
             * return draftBody;*/

            // var m = _languageStringGR.GetDbSet().Where((x) => x.Id == Id && x.Language.AbbName == langAddName).Include(x => x.Language).ToArray().FirstOrDefault();
        }
Ejemplo n.º 2
0
 public RegistrationService(IRoleService roleService,
                            IEmailService emailService,
                            INotificationService notificationService,
                            IPermanentConnectionService permanentConnectionService,
                            IUserService userService,
                            ILoginService loginService,
                            ScopedHttpContext httpContext,
                            RegistrationServiceConfiguration configuration)
 {
     _roleService                = roleService;
     _emailService               = emailService;
     _notificationService        = notificationService;
     _permanentConnectionService = permanentConnectionService;
     _userService                = userService;
     _loginService               = loginService;
     _httpContext                = httpContext.HttpContext;
     _configuration              = configuration;
 }
 /// <summary>
 /// Automatically provides a <see cref="ScopedHttpContext"/> service that enables scoped services
 /// to use the HttpContext.
 /// </summary>
 /// <remarks>
 /// This is much more efficient than the HttpContextAccessor. HttpContextAccessor remains the only
 /// way to have a singleton service depends on the HttpContext and must NEVER be used. Singleton
 /// services that MAY need the HttpContext must be designed with explicit HttpContext method parameter
 /// injection.
 /// <para>
 /// Scoped services however CAN easily depend on the HttpContext thanks to this ScopedHttpContext.
 /// </para>
 /// </remarks>
 /// <param name="builder">This Web host builder.</param>
 /// <returns>The builder.</returns>
 public static IWebHostBuilder UseScopedHttpContext(this IWebHostBuilder builder) => ScopedHttpContext.Install(builder);
 public HttpContextDependentService(ScopedHttpContext ctx)
 {
     _ctx = ctx.HttpContext;
 }