Esempio n. 1
0
 public OpmlController(
     ILogger <OpmlController> logger,
     CategoryService categoryService,
     BlogConfig blogConfig,
     BlogConfigurationService blogConfigurationService)
     : base(logger)
 {
     _categoryService = categoryService;
     _blogConfig      = blogConfig;
     _blogConfig.Initialize(blogConfigurationService);
 }
Esempio n. 2
0
 public SearchController(
     ILogger <OpmlController> logger,
     IOptions <AppSettings> settings,
     PostService postService,
     BlogConfig blogConfig,
     BlogConfigurationService blogConfigurationService)
     : base(logger, settings)
 {
     _postService = postService;
     _blogConfig  = blogConfig;
     _blogConfig.Initialize(blogConfigurationService);
 }
Esempio n. 3
0
 public CommentService(
     ILogger <CommentService> logger,
     IOptions <AppSettings> settings,
     BlogConfig blogConfig,
     BlogConfigurationService blogConfigurationService,
     IRepository <Comment> commentRepository,
     IRepository <CommentReply> commentReplyRepository) : base(logger, settings)
 {
     _blogConfig             = blogConfig;
     _commentRepository      = commentRepository;
     _commentReplyRepository = commentReplyRepository;
     _blogConfig.Initialize(blogConfigurationService);
 }
Esempio n. 4
0
        public ImageController(
            ILogger <ImageController> logger,
            IOptions <AppSettings> settings,
            IMemoryCache memoryCache,
            IAsyncImageStorageProvider imageStorageProvider,
            ISessionBasedCaptcha captcha,
            BlogConfig blogConfig,
            BlogConfigurationService blogConfigurationService)
            : base(logger, settings, memoryCache: memoryCache)
        {
            _blogConfig = blogConfig;
            _blogConfig.Initialize(blogConfigurationService);

            _imageStorageProvider = imageStorageProvider;
            _captcha = captcha;
        }
Esempio n. 5
0
        public SyndicationService(
            ILogger <SyndicationService> logger,
            IOptions <AppSettings> settings,
            BlogConfig blogConfig,
            BlogConfigurationService blogConfigurationService,
            IHttpContextAccessor httpContextAccessor,
            IRepository <Category> categoryRepository,
            IRepository <Post> postRepository) : base(logger, settings)
        {
            _blogConfig         = blogConfig;
            _categoryRepository = categoryRepository;
            _postRepository     = postRepository;
            _blogConfig.Initialize(blogConfigurationService);

            var acc = httpContextAccessor;

            _baseUrl = $"{acc.HttpContext.Request.Scheme}://{acc.HttpContext.Request.Host}";
        }
Esempio n. 6
0
        public EmailService(
            ILogger <EmailService> logger,
            IOptions <AppSettings> settings,
            IHostingEnvironment env,
            BlogConfig blogConfig,
            BlogConfigurationService blogConfigurationService,
            IRepository <Post> postRepository) : base(logger, settings)
        {
            _env            = env;
            _blogConfig     = blogConfig;
            _postRepository = postRepository;
            _blogConfig.Initialize(blogConfigurationService);

            var configSource = $@"{AppDomain.CurrentDomain.GetData(Constants.AppBaseDirectory)}\mailConfiguration.xml";

            if (!File.Exists(configSource))
            {
                throw new FileNotFoundException("Configuration file for EmailHelper is not present.", configSource);
            }

            if (EmailHelper == null)
            {
                var emailSettings = new EmailSettings(
                    _blogConfig.EmailConfiguration.SmtpServer,
                    _blogConfig.EmailConfiguration.SmtpUserName,
                    _blogConfig.EmailConfiguration.SmtpClearPassword,
                    _blogConfig.EmailConfiguration.SmtpServerPort)
                {
                    EnableSsl        = _blogConfig.EmailConfiguration.EnableSsl,
                    EmailDisplayName = _blogConfig.EmailConfiguration.EmailDisplayName,
                    SenderName       = _blogConfig.EmailConfiguration.EmailDisplayName
                };

                EmailHelper            = new EmailHelper(configSource, emailSettings);
                EmailHelper.EmailSent += (sender, eventArgs) =>
                {
                    if (sender is MailMessage msg)
                    {
                        Logger.LogInformation($"Email {msg.Subject} is sent, Success: {eventArgs.IsSuccess}");
                    }
                };
            }
        }
Esempio n. 7
0
        public SettingsController(
            ILogger <SettingsController> logger,
            IOptionsSnapshot <AppSettings> settings,
            IMemoryCache memoryCache,
            IApplicationLifetime appLifetime,
            EmailService emailService,
            FriendLinkService friendLinkService,
            BlogConfig blogConfig,
            BlogConfigurationService blogConfigurationService)
            : base(logger, settings, memoryCache: memoryCache)
        {
            _applicationLifetime = appLifetime;

            _blogConfig = blogConfig;
            _blogConfigurationService = blogConfigurationService;
            _blogConfig.Initialize(blogConfigurationService);

            _emailService      = emailService;
            _friendLinkService = friendLinkService;
        }
Esempio n. 8
0
        public CommentController(
            ILogger <CommentController> logger,
            IOptions <AppSettings> settings,
            IMemoryCache memoryCache,
            CommentService commentService,
            EmailService emailService,
            PostService postService,
            ISessionBasedCaptcha captcha,
            BlogConfig blogConfig,
            BlogConfigurationService blogConfigurationService,
            LinkGenerator linkGenerator)
            : base(logger, settings, memoryCache: memoryCache)
        {
            _blogConfig    = blogConfig;
            _linkGenerator = linkGenerator;
            _blogConfig.Initialize(blogConfigurationService);

            _commentService = commentService;
            _emailService   = emailService;
            _postService    = postService;
            _captcha        = captcha;
        }