Exemplo n.º 1
0
        public async Task <IActionResult> DeletePicture(int id)
        {
            PortfolioPicture portfolioPicture = await _context.PortfolioPicture.FirstOrDefaultAsync(pp => pp.Id == id && pp.RelookeuseId == int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value));

            if (portfolioPicture == null)
            {
                return(NotFound(id));
            }

            Task removeImageTask = _blobContainerClient.GetBlobClient(portfolioPicture.Picture.Split("/").Last()).DeleteIfExistsAsync();

            _context.Remove(portfolioPicture);
            Task removeInDbTasj = _context.SaveChangesAsync();
            await Task.WhenAll(removeImageTask, removeInDbTasj);

            return(NoContent());
        }