public PostController(FujiyBlogDatabase db, PostRepository postRepository, UserRepository userRepository, DateTimeUtil dateTimeUtil) { this.db = db; this.postRepository = postRepository; this.userRepository = userRepository; this.dateTimeUtil = dateTimeUtil; }
public CommentController(FujiyBlogDatabase db, SettingRepository settings, ICompositeViewEngine viewEngine, IEmailSender emailSender) { this.db = db; this.settings = settings; this.viewEngine = viewEngine; this.emailSender = emailSender; }
public static TResult FromCacheOrExecute <TResult>(FujiyBlogDatabase db, Expression <Func <TResult> > func, MemoryCacheEntryOptions cacheItemPolicy = null, bool condition = true) { if (func == null) { throw new ArgumentNullException("func"); } string key = ExtractKeyFromExpression(func); return(FromCacheOrExecute(db, func.Compile(), key, cacheItemPolicy, condition)); }
public WidgetViewComponent(FujiyBlogDatabase db, WidgetSettingRepository widgetSettingRepository) { this.db = db; this.widgetSettingRepository = widgetSettingRepository; if (widgets == null) { var diretorio = new DirectoryInfo(Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "Views", "Shared", "Components", "Widget")); widgets = (from file in diretorio.GetFiles() let fileWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName) where fileWithoutExtension != "Index" && fileWithoutExtension != "Widget" && !fileWithoutExtension.EndsWith("Edit") select fileWithoutExtension).ToArray(); } }
public static TResult FromCacheOrExecute <TResult>(FujiyBlogDatabase db, Func <TResult> func, string key, MemoryCacheEntryOptions cacheItemPolicy = null, bool condition = true) { if (func == null) { throw new ArgumentNullException(nameof(func)); } if (key == null) { throw new ArgumentNullException(nameof(key)); } string lastDatabaseChangeAtDb = db.LastDatabaseChange; if (lastDatabaseChangeAtDb != lastDatabaseChange) { lastDatabaseChange = lastDatabaseChangeAtDb; ClearCache(); } if (!condition) { return(func()); } object returnObject = DefaultCache.Get(key); bool hasValueAndIsSameType = (returnObject is TResult); if (hasValueAndIsSameType) { Task taskValue = returnObject as Task; if (taskValue != null && (taskValue.Status == TaskStatus.Canceled || taskValue.Status == TaskStatus.Faulted)) { hasValueAndIsSameType = false; } } if (hasValueAndIsSameType == false) { returnObject = func(); if (returnObject != null) { DefaultCache.Set(key, returnObject, cacheItemPolicy); } } return((TResult)returnObject); }
public WidgetViewComponent(FujiyBlogDatabase db, WidgetSettingRepository widgetSettingRepository) { this.db = db; this.widgetSettingRepository = widgetSettingRepository; if (widgets == null || widgets.Length == 0) { var widgetsViews = CompiledViewsHelper.GetViewsTypes <WidgetSetting>(); widgets = (from widgetView in widgetsViews let nameWithoutPrefix = widgetView.Name.Substring("Views_Shared_Components_Widget_".Length) where nameWithoutPrefix != "Index" && nameWithoutPrefix != "Widget" && !nameWithoutPrefix.EndsWith("Edit") select nameWithoutPrefix).ToArray(); } }
public static Post GetCompletePost(this FujiyBlogDatabase database, string slug, HttpContext httpContext) { Post post = database.Posts.WhereHaveRoles(httpContext).Include(x => x.Author).SingleOrDefault(x => x.Slug == slug); if (post == null) { return null; } database.Tags.Include(x=>x.PostTags).Where(x => x.PostTags.Any(y => y.PostId == post.Id)).Load(); database.Categories.Include(x=>x.PostCategories).Where(x => x.PostCategories.Any(y => y.PostId == post.Id)).Load(); database.PostComments.Include(x=>x.Author).WhereHaveRoles(httpContext).Load(); return post; }
public static TResult FromCacheOrExecute <TResult>(FujiyBlogDatabase db, Expression <Func <TResult> > func, string key = null, MemoryCacheEntryOptions cacheItemPolicy = null, bool condition = true) { string lastDatabaseChangeAtDb = db.LastDatabaseChange; if (lastDatabaseChangeAtDb != lastDatabaseChange) { lastDatabaseChange = lastDatabaseChangeAtDb; ClearCache(); } if (!condition) { return(func.Compile()()); } if (func == null) { throw new ArgumentNullException("func"); } if (string.IsNullOrEmpty(key)) { MethodCallExpression method = func.Body as MethodCallExpression; if (method == null) { throw new InvalidCachedFuncException("Body must be MethodCallExpression to auto generate a cache key"); } key = CacheKeyGenerator.GenerateKey(method); } object returnObject = DefaultCache.Get(key); if (!(returnObject is TResult)) { returnObject = func.Compile()(); if (returnObject != null) { DefaultCache.Set(key, returnObject, cacheItemPolicy); } } return((TResult)returnObject); }
public AccountController( FujiyBlogDatabase db, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager, SignInManager <ApplicationUser> signInManager, IOptions <IdentityCookieOptions> identityCookieOptions, IEmailSender emailSender, ISmsSender smsSender, ILoggerFactory loggerFactory) { this.db = db; _userManager = userManager; _roleManager = roleManager; _signInManager = signInManager; _externalCookieScheme = identityCookieOptions.Value.ExternalCookieAuthenticationScheme; _emailSender = emailSender; _smsSender = smsSender; _logger = loggerFactory.CreateLogger <AccountController>(); }
public WidgetController(FujiyBlogDatabase db, WidgetSettingRepository widgetSettingRepository) { this.db = db; this.widgetSettingRepository = widgetSettingRepository; }
public PageController(FujiyBlogDatabase db) { this.db = db; }
public CommentController(FujiyBlogDatabase db, SettingRepository settings, ICompositeViewEngine viewEngine) { this.db = db; this.settings = settings; this.viewEngine = viewEngine; }
public SearchController(FujiyBlogDatabase db, SettingRepository settings) { this.db = db; this.settings = settings; }
public PostController(PostRepository postRepository, SettingRepository settings, FujiyBlogDatabase db) { this.postRepository = postRepository; this.settings = settings; this.db = db; }
public CommentController(FujiyBlogDatabase db) { this.db = db; }
public SettingController(FujiyBlogDatabase db, SettingRepository settings, TelemetryConfiguration configuration) { this.db = db; this.settingRepository = settings; this.configuration = configuration; }
public PageController(FujiyBlogDatabase db, DateTimeUtil dateTimeUtil) { this.db = db; this.dateTimeUtil = dateTimeUtil; }
public UserController(FujiyBlogDatabase db, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager) { this.db = db; this.userManager = userManager; this.roleManager = roleManager; }