Beispiel #1
0
        public async Task <ActionResult <ErrorResponse> > UpdateNotebookAsync([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"));
                }

                if (notebook == null)
                {
                    return(ErrorResponse.Failure(ErrorCodes.InvalidBody, $"The request body does not contain a valid Notebook"));
                }

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

            return(ErrorResponse.Success());
        }