public IQueryable <Comment> SearchFor(Expression <Func <Comment, bool> > predicate) { using (var ctx = new BildGalleryContext()) { return(ctx.Comments.Where(predicate)); } }
public IQueryable <Photo> SearchFor(Expression <Func <Photo, bool> > predicate) { using (var ctx = new BildGalleryContext()) { return(ctx.Photos.Where(predicate)); } }
public IQueryable <Album> SearchFor(Expression <Func <Album, bool> > predicate) { using (var ctx = new BildGalleryContext()) { var find = ctx.Albums.Where(predicate); return(find); } }
public async Task EditAsync(Comment entity) { using (var ctx = new BildGalleryContext()) { ctx.Entry(entity).State = EntityState.Modified; await ctx.SaveChangesAsync(); } }
public async Task InsertAsync(Album entity) { using (var ctx = new BildGalleryContext()) { ctx.Entry(entity).State = EntityState.Added; await ctx.SaveChangesAsync(); } }
public async Task DeleteAsync(Comment entity) { using (var ctx = new BildGalleryContext()) { ctx.Comments.Remove(entity); await ctx.SaveChangesAsync(); } }
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(); } }
public async Task <List <Comment> > GetAll() { using (var ctx = new BildGalleryContext()) { var p = ctx.Comments .ToListAsync(); return(await p); } }
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); } }
public async Task <List <Photo> > GetAll() { using (var ctx = new BildGalleryContext()) { var p = ctx.Photos .Include(a => a.Album) .ToListAsync(); return(await p); } }
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); } }
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()); } }
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); } }
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(); } }
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(); } }
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(); } }
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); } }
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(); } }