Example #1
0
        public async Task <IActionResult> UrlExists(Client client, string oneNoteUrl, string matterLandingPageUrl)
        {
            string result = string.Empty;

            try
            {
                spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"];
                #region Error Checking
                ErrorResponse errorResponse = null;
                //if the token is not valid, immediately return no authorization error to the user
                if (errorResponse != null && !errorResponse.IsTokenValid)
                {
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.Unauthorized));
                }

                if (client == null && string.IsNullOrEmpty(oneNoteUrl) && string.IsNullOrEmpty(matterLandingPageUrl))
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message     = errorSettings.MessageNoInputs,
                        ErrorCode   = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.NotFound));
                }
                #endregion
                var oneNoteUrlExists = await sharedRepository.UrlExistsAsync(client, oneNoteUrl);

                var matterLandingUrlExists = await sharedRepository.UrlExistsAsync(client, matterLandingPageUrl);

                var urlExists = new
                {
                    OneNoteExists       = oneNoteUrlExists,
                    MatterLandingExists = matterLandingUrlExists
                };
                return(matterCenterServiceFunctions.ServiceResponse(urlExists, (int)HttpStatusCode.OK));
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }