コード例 #1
0
        public async Task <JsonResult> Post(Models.ApiModel apiModel)
        {
            var customHeadersList = new Dictionary <string, string>();
            var cCodeVal          = !string.IsNullOrEmpty(Request.Headers["CCode"]) ? Request.Headers["CCode"].ToString() : string.Empty;
            var uCodeVal          = !string.IsNullOrEmpty(Request.Headers["UCode"]) ? Request.Headers["UCode"].ToString() : string.Empty;

            customHeadersList.Add("CCode", cCodeVal);
            customHeadersList.Add("UCode", uCodeVal);
            string token = Request.Cookies["MAQTA-LOCAL-TOKEN"].Value;

            //ITokenContainer tokenContainer = new TokenContainer();

            if (token == null)
            {
                return(Json(new
                {
                    redirectUrl = Url.Action("LogOff", "Account"),
                    isRedirect = true
                }, JsonRequestBehavior.AllowGet));
            }
            var data = GetTargetData(apiModel);

            ApiHelper.Client.ApiClient client = new ApiHelper.Client.ApiClient(HttpClientInstance.Instance, token);
            GenericClient cb = new GenericClient(client);

            var response = await cb.Post(apiModel.ApiUrl, data, customHeadersList);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <JsonResult> Post(ADP.MG.Mamar.Web.Models.ApiModel apiModel)
        {
            ITokenContainer tokenContainer = new TokenContainer();

            if (tokenContainer.ApiToken == null)
            {
                return(Json(new
                {
                    redirectUrl = Url.Action("LogOff", "Account", new { area = string.Empty }),
                    isRedirect = true
                }, JsonRequestBehavior.AllowGet));
            }
            var data = GetTargetData(apiModel);

            ApiHelper.Client.ApiClient client = new ApiHelper.Client.ApiClient(HttpSubscriptionClient.Instance, tokenContainer);
            GenericClient cb       = new GenericClient(client);
            var           response = await cb.Post(apiModel.ApiUrl, data);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }