Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
 public ICollection <Site> List(int accessLevel)
 {
     using (var context = contextProvider.GetContext())
     {
         return(context.Sites.Where(s => s.AccessLevel <= accessLevel).ToList());
     }
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
 protected BaseRepository(
     IDbContextProvider <TEntity> contextProvider)
 {
     Collection = contextProvider.GetContext();
 }
Ejemplo n.º 5
0
 private IDbContext GetContext() => _dbContextProvider.GetContext();
Ejemplo n.º 6
0
 private DbSet <TEntity> GetTableInternal <TEntity>() where TEntity : class, IEntity
 {
     return(dbContextProvider.GetContext().Set <TEntity>());
 }
Ejemplo n.º 7
0
 /// <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));
Ejemplo n.º 9
0
 public TDbContext GetContext(object dbIndex = null)
 {
     return(_contextProvider.GetContext <TDbContext>(dbIndex));
 }
Ejemplo n.º 10
0
 public EFGenericRepository(IDbContextProvider contextProvider)
 {
     _context = contextProvider.GetContext();
     _dbSet   = _context.Set <TEntity>();
 }