/// <summary> /// Delete file /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <int> Delete(int id) { try { var file = await Load(id); if (file == null) { throw new NotFoundException("File not found"); } _context.Remove(file); await _context.SaveChangesAsync(); //Remove file from disk FileExtensions.DeleteFromDisk(file.Path); return(file.Id); } catch { throw; } }
public async Task <IActionResult> Delete(Guid fileGuid) { var file = await _dbContext.Files.FindAsync(fileGuid); if (file == null) { return(NotFound()); } _dbContext.Remove(file); await _dbContext.SaveChangesAsync(); return(NoContent()); }