예제 #1
0
        public async Task DeleteAsync(Picture pictureEntity)
        {
            dbSet.Remove(pictureEntity);
            context.Entry(pictureEntity).State = EntityState.Deleted;
            await context.SaveChangesAsync();                                                                   // Deletes the image from the database

            string imagePath = PictureDataHelpers.GeneratePictureFilePath(wwwRootPath, pictureEntity.FileName); // Gets the picture path

            File.Delete(imagePath);                                                                             // Deletes the image from the file system
        }
예제 #2
0
 public virtual void Delete(TEntity entity)
 {
     dbSet.Remove(entity);
     context.Entry(entity).State = EntityState.Deleted;
 }