Beispiel #1
0
        public void AddTag(string url, string name, string value, int accessLevel)
        {
            using (var context = contextProvider.GetContext())
            {
                var site = context.Sites.Include(s => s.Tags).FirstOrDefault(s => s.Url == url);
                if (site == null)
                {
                    site = new Site
                    {
                        Url         = url,
                        Tags        = new List <Tag>(),
                        AccessLevel = accessLevel
                    };

                    context.Sites.Add(site);
                }
                else if (site.AccessLevel < accessLevel)
                {
                    site.AccessLevel = accessLevel;
                }

                site.Tags.Add(new Tag
                {
                    Name  = name,
                    Site  = site,
                    Value = value
                });

                context.SaveChanges();
            }
        }
Beispiel #2
0
 public ICollection <Site> List(int accessLevel)
 {
     using (var context = contextProvider.GetContext())
     {
         return(context.Sites.Where(s => s.AccessLevel <= accessLevel).ToList());
     }
 }
Beispiel #3
0
        public async Task <ILookup <int, Datasource> > GetDatasourcesPerProject(IEnumerable <int> projectIds)
        {
            List <Datasource> datasources = new List <Datasource>();

            foreach (var projectId in projectIds.Distinct())
            {
                var context = _contextProvider.GetContext(projectId);
                var result  = await context.Datasource.Where(x => projectId == x.ProjectId).ToListAsync();

                datasources.AddRange(result);
            }

            return(datasources.ToLookup(x => x.ProjectId));
        }
Beispiel #4
0
 protected BaseRepository(
     IDbContextProvider <TEntity> contextProvider)
 {
     Collection = contextProvider.GetContext();
 }
 private IDbContext GetContext() => _dbContextProvider.GetContext();
Beispiel #6
0
 private DbSet <TEntity> GetTableInternal <TEntity>() where TEntity : class, IEntity
 {
     return(dbContextProvider.GetContext().Set <TEntity>());
 }
 /// <summary>
 ///   Gets the localized query.
 /// </summary>
 /// <param name="cultureId">The culture identifier.</param>
 /// <returns>The query.</returns>
 protected override IQueryable <Tables> GetLocalizedQuery(long cultureId) =>
 _dbContextProvider.GetContext().GetTables(cultureId);
		public SettingGroups Get(long pluginId, string code) => _dbContextProvider
			.GetContext()
			.Table<SettingGroups>()
			.FirstOrDefault(item => (item.OwnerPluginId == pluginId) && (item.Code == code));
Beispiel #9
0
 public TDbContext GetContext(object dbIndex = null)
 {
     return(_contextProvider.GetContext <TDbContext>(dbIndex));
 }
Beispiel #10
0
 public EFGenericRepository(IDbContextProvider contextProvider)
 {
     _context = contextProvider.GetContext();
     _dbSet   = _context.Set <TEntity>();
 }