public virtual async Task <T> Create(T entity)
        {
            using (MemeFolderDbContext context = _contextFactory.CreateDbContext(null))
            {
                EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createdResult.Entity);
            }
        }
Example #2
0
        public virtual async Task <bool> Delete(Guid guid)
        {
            using (MemeFolderDbContext context = _contextFactory.CreateDbContext(null))
            {
                MemeTagNode entity = await context.MemeTagNodes.FirstOrDefaultAsync(e => e.Id == guid);

                context.MemeTagNodes.Remove(entity);

                await context.SaveChangesAsync();

                return(true);
            }
        }
        public virtual async Task <Folder> Get(Guid guid)
        {
            using (MemeFolderDbContext context = _contextFactory.CreateDbContext(null))
            {
                Folder entity = await Task.FromResult(context.Folders
                                                      .Include(f => f.Memes)
                                                      .Include(f => f.Folders)
                                                      .ThenInclude(f => f.Folders)
                                                      .FirstOrDefault(e => e.Id == guid));

                return(entity);
            }
        }