Exemplo n.º 1
0
        public async Task <IActionResult> GetSelf()
        {
            // Pull manager ID from the HTTP context
            string managerId = HttpContext.User.Identity.Name;

            try
            {
                // Use the manager ID to pull manager information.
                return(Ok(await _managerService.GetSelf(managerId)));
            }
            catch (ManagerNotFoundException e)
            {
                // Error: The manager specified in the request context does not exist.
                // This shouldn't really occur, since the authentication handler should fail before the request gets to the endpoint.
                _logger.LogError(e, "Session managerId resolved to unknown manager. [mId: {managerId}]", managerId);

                return(BadRequest(APIError.ManagerNotFound()));
            }
            catch (Exception e)
            {
                // Error: Unknown error.
                _logger.LogError(e, "Failed to pull authenticated manager information. [mId: {managerId}]", managerId);

                return(BadRequest(APIError.UnknownError()));
            }
        }