public async Task <FileToDatabase> RemoveImage(FileToDatabaseDto dto) { var imageId = await _context.FileToDatabase .FirstOrDefaultAsync(x => x.Id == dto.Id); _context.FileToDatabase.Remove(imageId); await _context.SaveChangesAsync(); return(imageId); }
public async Task <IActionResult> RemoveImage(ImagesViewModel file) { var dto = new FileToDatabaseDto() { Id = file.ImageId, }; var image = await _spaceshipService.RemoveImage(dto); if (image == null) { return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); }