public I18nService(WebSpecDbContext dbContext, IHttpContextAccessor httpContextAccessor, ILogger <I18nService> logger) { this.dbContext = dbContext; this.httpContextAccessor = httpContextAccessor; this.logger = logger; // Load all supported currencies and languages from the database logger.LogDebug($"Attempting to load all available currencies and languages from the database."); SupportedCurrencies = dbContext.Currencies .Select(x => new SupportedCurrency { Code = x.Id, Title = x.Title, IsDefault = x.IsDefault }) .ToList(); SupportedLanguages = dbContext.Languages .Select(x => new SupportedLanguage { Code = x.Id, Title = x.Title, IsDefault = x.IsDefault }) .ToList(); logger.LogInformation($"Loaded {SupportedCurrencies.Count} supported currencies and {SupportedLanguages.Count} supported languages from the database."); }
/// <summary> /// Creates a new instance of <see cref="EntityServiceBase{T}"/> /// </summary> /// <param name="dbContext">Instance of <see cref="WebSpecDbContext"/></param> /// <param name="entityDao">Instance of <see cref="DbSet{T}"/> which serves as DAO</param> /// <param name="logger">Instance of <see cref="ILogger"/></param> /// <param name="entityName">Name of the managed entity. Will appear in logs</param> public EntityServiceBase(WebSpecDbContext dbContext, DbSet <T> entityDao, ILogger <EntityServiceBase <T> > logger, string entityName) { this.dbContext = dbContext; this.entityDao = entityDao; this.logger = logger; this.entityName = entityName; }
public ProductService(WebSpecDbContext dbContext, II18nService i18nService, ILogger <ProductService> logger, IImageService imageService, IWishlistService wishlistService) { this.dbContext = dbContext; this.i18nService = i18nService; this.logger = logger; this.imageService = imageService; this.wishlistService = wishlistService; }
protected WebSpecDbContext ProvideDbContext(SqliteConnection connection) { var options = new DbContextOptionsBuilder <WebSpecDbContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new WebSpecDbContext(options)) { context.Database.EnsureCreated(); } return(new WebSpecDbContext(options)); }
public CategoryService(WebSpecDbContext dbContext, ILogger <CategoryService> logger) : base(dbContext, dbContext.Categories, logger, entityName) { }
public UserService(WebSpecDbContext dbContext, ILogger <UserService> logger) : base(dbContext, dbContext.Users, logger, entityName) { }
/// <summary> /// Implementation of <see cref="IImageService"/> /// </summary> /// <param name="dbContext">Database Context</param> public ImageService(WebSpecDbContext dbContext, ILogger <ImageService> logger) { this.dbContext = dbContext; this.logger = logger; }
public OrderService(ILogger <OrderService> logger, WebSpecDbContext dbContext) { this.logger = logger; this.dbContext = dbContext; }
public WishlistService(WebSpecDbContext dbContext, ILogger <WishlistService> logger) { this.dbContext = dbContext; this.logger = logger; }