public async Task <ExistingFilePath> RemoveImage(ExistingFilePathDto dto) { var photoId = await _context.ExistingFilePath .FirstOrDefaultAsync(x => x.Id == dto.Id); _context.ExistingFilePath.Remove(photoId); await _context.SaveChangesAsync(); return(photoId); }
public async Task <IActionResult> RemoveImage(ExistingFilePathViewModel file) { var dto = new ExistingFilePathDto() { Id = file.PhotoId, }; var photo = await _productService.RemoveImage(dto); if (photo == null) { return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); }