コード例 #1
0
ファイル: SurveysController.cs プロジェクト: TK-Kirk/CBR4
        public IHttpActionResult SurveyAction([FromUri] int routerContactId, [FromUri] int hostId, [FromUri] int projectId, [FromUri] string surveyURL)
        {
            //1. save record in RouterAction table
            //2. the transactionid needs to be appended to the url
            //3. the varible name that the transId gets assigned to varies by host

            //return Ok(new Uri(Request.RequestUri, RequestContext.VirtualPathRoot));
            //returns
            //http://devmapi.cashbackresearch.com/

            try
            {
                //var compare = Utility.HashHmacMD5("unique_user_id=b1e269bc-99a5-4b96-a095-06a9cd56d446", ConfigurationManager.AppSettings["YourSurveysSecretKey"]);

                var _manager     = new RouterManager();
                var routerAction = _manager.SetSurveyAction(routerContactId, hostId, projectId, surveyURL, Utility.GetClientIpAddress());


                //TODO append TransactionID. Maybe only on Your Surveys.
                //TODO For precision sample, waiting to see if the transid comes back or we just have to use survey and userguid

                string newUrl = null;
                if (hostId == (int)RouterHost.YourSurvey)
                {
                    //surveyURL = $"{surveyURL}&supplier_sub_id={transationID}&supplier_sub_id2={routerContactId}";
                    surveyURL = $"{surveyURL}&ssi2={routerAction.TransactionId}&ssi3={routerContactId}";
                    //newUrl = CreateUrlForYourSurveys(surveyURL);
                }
                if (hostId == (int)RouterHost.PrecisionSample)
                {
                    surveyURL = $"{surveyURL}&sub_id={routerAction.TransactionId}";
                }

                routerAction.PostedUrl = surveyURL;
                _manager.SetRouterActionUrl(routerAction);


                return(Redirect(surveyURL));
                //return Redirect(newUrl);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            //var response = actionContext.Request.CreateResponse(HttpStatusCode.Redirect);
            //response.Headers.Location = new Uri("https://www.stackoverflow.com");
            //actionContext.Response = response;
        }