public static string POST_RequestAsync_sub(string uri, pensionAppSubModel json, int count = 0)
        {
            string          ResponseString = "";
            HttpWebResponse response       = null;

            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
                var request = (HttpWebRequest)WebRequest.Create(uri);
                request.Accept = "application/json";
                request.Method = "POST";

                // serialize into json string
                var myContent = JsonConvert.SerializeObject(json);

                var data = Encoding.ASCII.GetBytes(myContent);

                request.ContentType   = "application/json";
                request.ContentLength = data.Length;

                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                response = (HttpWebResponse)request.GetResponse();

                ResponseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    string mappath2  = HttpContext.Current.Server.MapPath("pensionAppExcptionlogsSubLogs");
                    Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath2, "error from POST_RequestAsync:" + ex.Message.ToString() + uri));

                    response       = (HttpWebResponse)ex.Response;
                    ResponseString = "Some error occured: " + response.StatusCode.ToString();
                }
                else
                {
                    ResponseString = "Some error occured: " + ex.Status.ToString();
                }
                throw ex;
            }
            return(ResponseString);
        }
        public IHttpActionResult pensionAppSub(dynamic data)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                string serialized_data = token_gen.Authorize_aesdecrpty(data);

                string mappath2  = HttpContext.Current.Server.MapPath("pensionAppSubLogs");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log(mappath2, serialized_data));

                pensionAppSubModel rootobj = JsonConvert.DeserializeObject <pensionAppSubModel>(serialized_data);
                return(Ok(pensionDeptHelper.pensionAppSub(rootobj)));
            }
            catch (Exception ex)
            {
                objdata.status = false;
                objdata.result = ex.Message.ToString();
            }
            return(Ok(objdata));
        }
        public static dynamic pensionAppSub(pensionAppSubModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                if (obj.pensionType == "3" && string.IsNullOrEmpty(obj.disabilityId))
                {
                    objdata.status = false;
                    objdata.result = "Please Enter SADAREM ID";
                    return(objdata);
                }

                obj.encrypted_data = obj.encrypted_data.Replace(" ", "+");
                string   decrypted_text = EncryptDecryptAlgoritham.DecryptStringAES(obj.encrypted_data, "3fee5395f01bee349feed65629bd442a", obj.iv);
                decModel decData        = JsonConvert.DeserializeObject <decModel>(decrypted_text);

                tokenModel objToken = new tokenModel();
                objToken.username   = "******";
                objToken.password   = "******";
                objToken.wdsLoginId = decData.USERNAME;

                string tokenResponse = string.Empty;
                try
                {
                    tokenResponse = POST_RequestAsync(tokenrUrl, JsonConvert.SerializeObject(objToken));
                }
                catch (Exception ex)
                {
                    objdata.status = false;
                    objdata.result = "RESPONSE FROM PENSION DEPT : " + ex.Message.ToString();
                    return(objdata);
                }

                tokenResponseModel tokenRespObj = JsonConvert.DeserializeObject <tokenResponseModel>(tokenResponse);
                if (string.IsNullOrEmpty(tokenRespObj.Token))
                {
                    objdata.status = false;
                    objdata.result = "No Response from pension department token service !!!, Please try after some time";
                    return(objdata);
                }

                obj.loginId       = decData.USERNAME;
                obj.userName      = "******";
                obj.password      = "******";
                obj.token         = tokenRespObj.Token;
                obj.transactionId = decData.PS_TXN_ID;
                obj.systemIp      = HttpContext.Current.Request.UserHostAddress;

                string subResponse = string.Empty;
                try
                {
                    subResponse = POST_RequestAsync_sub(subrUrl, obj);
                }
                catch (Exception ex)
                {
                    objdata.status = false;
                    objdata.result = "RESPONSE FROM PENSION DEPT : " + ex.Message.ToString();
                    return(objdata);
                }
                subRespModel subResp = JsonConvert.DeserializeObject <subRespModel>(subResponse);

                if (subResp.Response != null && subResp.Response.status_Code == "101")
                {
                    transactionModel objTrans = new transactionModel();
                    objTrans.TYPE        = "2";
                    objTrans.TXN_ID      = decData.PS_TXN_ID;
                    objTrans.DEPT_ID     = "31";
                    objTrans.DEPT_TXN_ID = subResp.Response.BenTransId;
                    objTrans.BEN_ID      = obj.aadharNumber;
                    objTrans.STATUS_CODE = subResp.Response.status_Code;
                    objTrans.REMARKS     = subResp.Response.remarks;

                    transactionHelper transHel = new transactionHelper();
                    DataTable         dt       = transHel.transactionInsertion(objTrans);
                    if (dt != null && dt.Rows.Count > 0 && dt.Rows[0][0].ToString() == "1")
                    {
                        objdata.status = true;
                        objdata.result = subResp.Response.remarks + ", YOUR Grievance ID IS : " + subResp.Response.BenTransId;
                    }
                    else
                    {
                        objdata.status = false;
                        objdata.result = "Failed to submit Details, Please try again !!!";
                    }
                }
                else
                {
                    objdata.status = false;
                    objdata.result = "RESPONSE FROM PENSION DEPT : " + subResp.Response.remarks;
                }
            }
            catch (Exception ex)
            {
                objdata.status = false;
                objdata.result = ex.Message.ToString();
            }
            return(objdata);
        }