Example #1
0
        public async Task <ActionResult <ModelBase> > DeleteNotebookAsync([FromHeader] string authorization, [FromQuery] int?id)
        {
            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 (id == null)
                {
                    return(ErrorResponse.Failure(ErrorCodes.MissingParameter, $"Parameter { nameof(id) } is missing"));
                }

                await notebooks.DeleteAsync(id.Value);
            }
            catch (Exception e)
            {
                return(ErrorResponse.Failure(ErrorCodes.GeneralFailure, e));
            }

            return(ErrorResponse.Success());
        }