public async Task DeleteAsync(Comment entity) { using (var ctx = new BildGalleryContext()) { ctx.Comments.Remove(entity); await ctx.SaveChangesAsync(); } }
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(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 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 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(); } }