コード例 #1
0
        public async Task <ActionResult <ListResponse <Notebook> > > GetNotebooksAsync([FromHeader] string authorization)
        {
            if (authorization == null)
            {
                return(ErrorResponse.Failure <ListResponse <Notebook> >(ErrorCodes.MissingToken, "Missing token"));
            }

            try
            {
                if (!await CheckTokenAsync(authorization))
                {
                    return(ErrorResponse.Failure <ListResponse <Notebook> >(ErrorCodes.InvalidToken, "Invalid or expired token"));
                }

                List <Data.Notebook> list = new List <Data.Notebook>(await notebooks.GetAllAsync());
                return(new ListResponse <Notebook> {
                    List = list.ConvertAll((item) => item.ToWebNotebook())
                });
            }
            catch (Exception e)
            {
                return(ErrorResponse.Failure <ListResponse <Notebook> >(ErrorCodes.GeneralFailure, e));
            }
        }