예제 #1
0
 public IQueryable <Comment> SearchFor(Expression <Func <Comment, bool> > predicate)
 {
     using (var ctx = new BildGalleryContext())
     {
         return(ctx.Comments.Where(predicate));
     }
 }
예제 #2
0
 public IQueryable <Photo> SearchFor(Expression <Func <Photo, bool> > predicate)
 {
     using (var ctx = new BildGalleryContext())
     {
         return(ctx.Photos.Where(predicate));
     }
 }
예제 #3
0
 public IQueryable <Album> SearchFor(Expression <Func <Album, bool> > predicate)
 {
     using (var ctx = new BildGalleryContext())
     {
         var find = ctx.Albums.Where(predicate);
         return(find);
     }
 }
예제 #4
0
 public async Task EditAsync(Comment entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         ctx.Entry(entity).State = EntityState.Modified;
         await ctx.SaveChangesAsync();
     }
 }
예제 #5
0
 public async Task InsertAsync(Album entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         ctx.Entry(entity).State = EntityState.Added;
         await ctx.SaveChangesAsync();
     }
 }
예제 #6
0
 public async Task DeleteAsync(Comment entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         ctx.Comments.Remove(entity);
         await ctx.SaveChangesAsync();
     }
 }
예제 #7
0
 public async Task DeleteAsync(Guid entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         var p = ctx.Albums.FirstOrDefault(x => x.AlbumId == entity);
         ctx.Albums.Remove(p);
         await ctx.SaveChangesAsync();
     }
 }
예제 #8
0
 public async Task <List <Comment> > GetAll()
 {
     using (var ctx = new BildGalleryContext())
     {
         var p = ctx.Comments
                 .ToListAsync();
         return(await p);
     }
 }
예제 #9
0
 public async Task <Comment> GetByIdAsync(Guid id)
 {
     using (var ctx = new BildGalleryContext())
     {
         var find = ctx.Comments.Where(p => p.Id == id)
                    .FirstOrDefaultAsync();
         return(await find);
     }
 }
예제 #10
0
 public async Task <List <Photo> > GetAll()
 {
     using (var ctx = new BildGalleryContext())
     {
         var p = ctx.Photos
                 .Include(a => a.Album)
                 .ToListAsync();
         return(await p);
     }
 }
예제 #11
0
 public async Task <List <Photo> > GetPhotoByAlbumIdAsync(Guid id)
 {
     using (var ctx = new BildGalleryContext())
     {
         var find = ctx.Photos.Where(p => p.AlbumId == id)
                    //.Include(p => p.User)
                    //.Include(p => p.Comments)
                    .ToListAsync();
         return(await find);
     }
 }
예제 #12
0
 public IEnumerable <Album> GetAll()
 {
     using (var ctx = new BildGalleryContext())
     {
         var getAll = ctx.Albums
                      //.Include(u => u.User)
                      .Include(c => c.Comments)
                      .Include(p => p.Photos);
         return(getAll.ToList());
     }
 }
예제 #13
0
 public async Task <Photo> GetByIdAsync(Guid id)
 {
     using (var ctx = new BildGalleryContext())
     {
         var find = ctx.Photos.Where(p => p.PhotoId == id)
                    .Include(p => p.Album)
                    .Include(p => p.Comments)
                    .FirstOrDefaultAsync();
         return(await find);
     }
 }
예제 #14
0
        public async Task EditAsync(Album entity)
        {
            using (var ctx = new BildGalleryContext())
            {
                var EA = ctx.Albums.FirstOrDefault(x => x.AlbumId == entity.AlbumId);
                //EA.AlbumId = entity.AlbumId;
                EA.AlbumName   = entity.AlbumName;
                EA.AlbumDate   = entity.AlbumDate;
                EA.Description = entity.Description;

                //ctx.Entry<Album>(entity).State = EntityState.Modified;
                await ctx.SaveChangesAsync();
            }
        }
예제 #15
0
 public async Task InsertAsync(Comment entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         var insertComm = new Comment();
         insertComm.Id      = entity.Id;
         insertComm.AlbumId = entity.AlbumId;
         insertComm.UserId  = entity.UserId;
         insertComm.PhotoId = entity.PhotoId;
         insertComm.Content = entity.Content;
         insertComm.Date    = entity.Date;
         ctx.Comments.Add(insertComm);
         await ctx.SaveChangesAsync();
     }
 }
예제 #16
0
 public async Task InsertAsync(Photo entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         var addPhoto = new Photo();
         addPhoto.AlbumId     = entity.AlbumId;
         addPhoto.PhotoId     = entity.PhotoId;
         addPhoto.PhotoDate   = entity.PhotoDate;
         addPhoto.PhotoName   = entity.PhotoName;
         addPhoto.PhotoPath   = entity.PhotoPath;
         addPhoto.Description = entity.Description;
         ctx.Photos.Add(addPhoto);
         await ctx.SaveChangesAsync();
     }
 }
예제 #17
0
        public async Task <Album> GetByIdAsync(Guid id)
        {
            using (var ctx = new BildGalleryContext())
            {
                //var find = (from t in ctx.Albums
                //            where t.AlbumId == id
                //            select t).FirstOrDefaultAsync();
                var find = ctx.Albums.Where(p => p.AlbumId == id)
                           //.Include(p => p.User)
                           .Include(p => p.Comments)
                           .Include(p => p.Photos)
                           .FirstOrDefaultAsync();

                return(await find);
            }
        }
예제 #18
0
 public async Task EditoUpdateAsync(Photo entity)
 {
     using (var ctx = new BildGalleryContext())
     {
         var updatePhoto = ctx.Photos.Where(p => p.PhotoId == entity.PhotoId)
                           .Include(p => p.Comments)
                           .Include(p => p.Album)
                           .FirstOrDefault();
         if (updatePhoto != null)
         {
             updatePhoto.AlbumId     = entity.AlbumId;
             updatePhoto.PhotoId     = entity.PhotoId;
             updatePhoto.PhotoDate   = entity.PhotoDate;
             updatePhoto.PhotoName   = entity.PhotoName;
             updatePhoto.PhotoPath   = entity.PhotoPath;
             updatePhoto.Description = entity.Description;
         }
         await ctx.SaveChangesAsync();
     }
 }