Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
    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)));
    }