コード例 #1
0
        public async Task <ActionResult <GalleryDTO> > CreateGallery(GalleryCreationDTO creationDto)
        {
            Guid userId = new Guid(HttpContext.User.Identity.Name);

            try
            {
                GalleryDTO dto = await _galleryService.CreateGalleryAsync(userId, creationDto);

                return(CreatedAtAction(nameof(GetGallery), new { id = dto.Id }, dto));
            }
            catch (Exception ex)
            {
                var problemDetails = new ProblemDetails
                {
                    Title    = "An unexpected error occurred.",
                    Status   = StatusCodes.Status500InternalServerError,
                    Detail   = "Unable to create 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));
            }
        }