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 }
public virtual void Delete(TEntity entity) { dbSet.Remove(entity); context.Entry(entity).State = EntityState.Deleted; }