public async Task <ActionResult <GalleryDTO> > PutGallery(Guid galleryId, GalleryPutDTO galleryPutDTO) { Guid userId = new Guid(HttpContext.User.Identity.Name); if (await _galleryService.DoesGalleryExistAsync(galleryId) == false) { return(NotFound()); } if (await _galleryService.IsGalleryOwnedByUserAsync(galleryId, userId) == false) { return(Unauthorized()); } try { GalleryDTO galleryDto = await _galleryService.PutGalleryAsync(userId, galleryId, galleryPutDTO); return(CreatedAtAction(nameof(GetGallery), new { id = galleryDto.Id }, galleryDto)); } catch (Exception ex) { var problemDetails = new ProblemDetails { Title = "An unexpected error occurred.", Status = StatusCodes.Status500InternalServerError, Detail = "Unable to update the gallery at this moment due to an error, the error has been logged and sent to the developers for fixing.", Instance = HttpContext.TraceIdentifier, }; return(StatusCode(StatusCodes.Status500InternalServerError, problemDetails)); } }