コード例 #1
0
ファイル: APIController.cs プロジェクト: mkbiltek2019/MyProjs
        //Async task for Saving user details
        public async Task <string> SaveUserinfo(PersonalizationRequsetDTO userdata, string userid)
        {
            string rspSaveinfo = string.Empty;

            try
            {
                string WebApiRootURL = SettingsHelper.WebApiUrl;
                if (!string.IsNullOrEmpty(WebApiRootURL))
                {
                    //Creates the enpoint uri to be called
                    StringBuilder EndPointUri          = new StringBuilder(WebApiRootURL);
                    string        api                  = string.Format(SettingsHelper.PersonalizationAPIUser, userid);
                    Uri           spotlightEndPointUri =
                        new Uri(EndPointUri.Append(string.Format(api)).ToString());
                    Helper JsonHelperObj = new Helper();
                    //Gets the response returned by the Personalization API
                    rspSaveinfo = await JsonHelperObj.APIPostCall(string.Format(spotlightEndPointUri.ToString()), userdata);
                }
                else
                {
                    //Write the trace in db that no url exists
                    LoggerHelper.WriteToLog("WebApiRootURL URL is null", CoreConstants.Priority.High, CoreConstants.Category.Error);
                    return(null);
                }
            }
            catch (Exception exception)
            {
                // logging an error if in case some exception occurs
                LoggerHelper.WriteToLog(exception, "Error while fetching the most popular videos" + exception.ToString());
                throw new DataAccessException("Data Access Exception:-Error while saving user info");
            }
            return(rspSaveinfo);
        }