Exemple #1
0
        public async Task <ActionResult <ErrorResponse> > CreateNotebookAsync([FromHeader] string authorization, [FromBody] Notebook notebook)
        {
            if (authorization == null)
            {
                return(ErrorResponse.Failure(ErrorCodes.MissingToken, "Missing token"));
            }

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

                await notebooks.CreateAsync(notebook.ToDataNotebook());
            }
            catch (Exception e)
            {
                return(ErrorResponse.Failure(ErrorCodes.GeneralFailure, e));
            }

            return(ErrorResponse.Success());
        }