Example #1
0
        public static async Task <IActionResult> GetImage(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "images/{id}")] HttpRequest req,
            TraceWriter log,
            string id)
        {
            // get the user ID
            if (!await UserAuthenticationService.GetUserIdAsync(req, out var userId, out var responseResult))
            {
                return(responseResult);
            }

            // get the image
            try
            {
                var imageNote = await ImagesService.GetImageNoteAsync(id, userId);

                if (imageNote == null)
                {
                    return(new NotFoundResult());
                }

                return(new OkObjectResult(imageNote));
            }
            catch (Exception ex)
            {
                log.Error("Unhandled exception", ex);
                return(new ExceptionResult(ex, false));
            }
        }