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