Esempio n. 1
0
        public IHttpActionResult PutUser_Vehicle(long id, User_Vehicle user_Vehicle)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user_Vehicle.srno)
            {
                return(BadRequest());
            }

            db.Entry(user_Vehicle).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!User_VehicleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public int createTollPayCustomer(User u)
        {
            try
            {
                User ue = db.Users.Where(i => i.username == u.username).FirstOrDefault();
                if (ue == null)
                {
                    db.Users.Add(u);
                    db.SaveChanges();
                }
                else
                {
                    ue.password       = u.password;
                    ue.userEmail      = u.userEmail;
                    ue.mobno1         = u.mobno1;
                    ue.mobno2         = u.mobno2;
                    ue.userRollstatus = "C";
                    db.SaveChanges();
                }
                string smsmsg;
                smsmsg = "Dear User, Use Web https://Tollpay.in | App http://bit.ly/34kCC5C  with Username="******",Password="******"smsfrom", u.mobno1, smsmsg);
                ns.sendemail(u.userEmail, "", "Welcome to TollPay.IN", smsmsg);

                return(db.Users.Where(i => i.username == u.username).FirstOrDefault().srno);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public IHttpActionResult PutIssuerFASTag(int id, IssuerFASTag issuerFASTag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != issuerFASTag.srno)
            {
                return(BadRequest());
            }

            db.Entry(issuerFASTag).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IssuerFASTagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        public clsstatuscode ForgotPassword(string username)
        {
            User u = db.Users.Where(l => l.username == username).FirstOrDefault();

            if (u != null)
            {
                int OTP = RandomPassword();
                db.Users.Where(l => l.username == username).FirstOrDefault().TempOTP = OTP;
                db.SaveChanges();
                string smsmsg;
                smsmsg = "Dear " + u.userEmail + " , Your OTP to change Password for https://TollPay.IN is -. -" + OTP;
                ns.sendsms("smsfrom", u.username, smsmsg);
                // ns.sendemail(u.userEmail, "", "TollPay.IN OTP To Reset Password", smsmsg);
                clsstatuscode cs = new clsstatuscode();
                cs.statuscode = 000;
                cs.statusdesc = "OTP Send to Registered Mobile No - XXXXX" + u.username.Substring(u.username.Length - 4);
                return(cs);
            }
            else
            {
                clslststatuscode css = new clslststatuscode();
                clsstatuscode    scd = css.getstatuscodes().Where(s => s.statuscode == 020).FirstOrDefault();

                return(scd);
            }
        }
Esempio n. 5
0
 public HttpResponseMessage BankUpdateCFI(HttpRequestMessage request, Bank_UpdateCIFAPI bucif)
 {
     if (!ModelState.IsValid || bucif == null)
     {
         return(new HttpResponseMessage(HttpStatusCode.BadRequest));
     }
     db.Bank_UpdateCIFAPI.Add(bucif);
     db.SaveChanges();
     return(request.CreateResponse(HttpStatusCode.OK, bucif));
 }
Esempio n. 6
0
        private async Task <string> GetTokenFromIndus()
        {
            DP_TPEntities db     = new DP_TPEntities();
            string        uri    = "https://fastag.gitechnology.in/indusindAPI/api/Authentication/RequestToken";
            var           client = new RestClient(uri);

            client.Timeout = -1;
            var    request   = new RestRequest(Method.GET);
            string nonce     = OAuthBase.GenerateNonce();
            string timeStamp = OAuthBase.GenerateTimeStamp();
            string sig       = OAuthBase.GenerateSignature(new Uri(uri), Consumerkey, ConsumerSecret, null, null, "GET", timeStamp, nonce, OAuthBase.HMACSHA1SignatureType);

            sig = HttpUtility.UrlEncode(sig);
            string authString = String.Format(@"OAuth oauth_consumer_key=""{0}"",oauth_signature_method=""HMAC-SHA1"",oauth_timestamp=""{1}"",oauth_nonce=""{2}"",oauth_version=""1.0"",oauth_signature=""{3}""""", Consumerkey, timeStamp, nonce, sig);

            request.AddHeader("Authorization", authString);
            request.AddHeader("Connection", "Keep-Alive");
            IRestResponse response = client.Execute(request);

            Console.WriteLine(response.Content);
            TokenResponse    json = JsonConvert.DeserializeObject <TokenResponse>(response.Content);
            var              x    = json.ResponseData;// this extracts the encrypted requesttoken;
            string           s1   = EncryptionsUtility.AES_DECRYPT(x, AESkey);
            clsTokenResponse obj  = JsonConvert.DeserializeObject <clsTokenResponse>(s1);

            Console.WriteLine(obj.ResponseContent.Token);
            db.IndusInd_Token_Secrete.Add(new IndusInd_Token_Secrete()
            {
                CreateDate = DateTime.Now, Token = obj.ResponseContent.Token, TokenSecrete = obj.ResponseContent.TokenSecret
            });
            db.SaveChanges();
            return(s1);
        }
Esempio n. 7
0
        public clsWalletrequest()
        {
            string        key   = "8E41AEF6156CF2221EF6A2EA6950A934";
            string        vguid = Guid.NewGuid().ToString(); //DateTime.Now.ToString("yyyyMMddHHmmssfffffff");
            Walletrequest wr    = new Walletrequest();
            Subheader     sub   = new Subheader()
            {
                serviceRequestVersion = "1.0",
                serviceRequestId      = "WALLET",
                requestUUID           = vguid,
                channelId             = "DIGI"
            };

            wr.SubHeader = sub;
            Walletrequestbody wrb = new Walletrequestbody();
            var jsonString        = JsonConvert.SerializeObject(wrb);

            Console.WriteLine("Walletrequestbody plan -" + jsonString.ToString());

            wr.WalletRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, key);
            this.WalletRequest            = wr;
            db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
            {
                RequestGuid = vguid
                ,
                request = jsonString
            });
            db.SaveChanges();
        }
Esempio n. 8
0
        public IHttpActionResult PostTranP_Truck_Trips(TranP_BookTrip tt)
        {
            db.TranP_TruckTrips.Add(tt.tranP_trucktrip);
            db.SaveChanges();
            db.TranP_TruckTrip_Payment.Add(tt.tranP_truckTrip_payment);
            db.SaveChanges();
            string smsmsg;

            smsmsg = "Dear Customer, Rs. " + tt.tranP_trucktrip.FareCost + " Paid via " + tt.tranP_trucktrip.tripDate + "for Truck Trip Src-" + tt.tranP_trucktrip.tripStartLocation + "Dest- " + tt.tranP_trucktrip.tripEndLocation;
            ns.sendsms("smsfrom", tt.tranP_trucktrip.DriverMobileNo, smsmsg);
            string userEmail = db.Users.Where(o => o.srno == tt.tranP_trucktrip.userid).FirstOrDefault().userEmail;

            ns.sendemail(userEmail, "", "TollPay.IN Truck Trip Booked", smsmsg);

            var a = new { TruckTripId = tt.tranP_trucktrip.srno };

            return(Ok(a));
        }
Esempio n. 9
0
        public IHttpActionResult Post(string username)
        {
            int           userid        = db.Users.Where(l => l.username == username).Select(u => u.srno).FirstOrDefault();
            TollPayWallet tollpaywallet = new TollPayWallet();

            tollpaywallet.UserID       = Convert.ToInt32(userid);
            tollpaywallet.WalletAmount = Convert.ToDecimal(0);
            db.TollPayWallets.Add(tollpaywallet);
            db.SaveChanges();
            return(CreatedAtRoute("DefaultApi", new { id = tollpaywallet.SrNo }, tollpaywallet));
        }
Esempio n. 10
0
        public int createTollPayCustomer(IndusInd_CustomerRegistration icr)
        {
            User u = new User();

            u.password       = Convert.ToString(GenerateRandomNo());
            u.FirstName      = icr.FirstName;
            u.LastName       = icr.LastName;
            u.userRollstatus = "C";
            u.mobno1         = icr.MobileNumber;
            u.userEmail      = icr.EmailID;
            u.address        = "FN=" + icr.FirstName + "|LN=" + icr.LastName + "|PAN=" + icr.PANNo + "|AadharNo=" + icr.Aadhaarno;
            u.status         = "a";
            u.username       = icr.MobileNumber;

            User ue = db.Users.Where(i => i.username == u.username).FirstOrDefault();

            if (ue == null)
            {
                db.Users.Add(u);
                db.SaveChanges();
            }
            else
            {
                ue.password       = u.password;
                ue.userEmail      = u.userEmail;
                ue.FirstName      = icr.FirstName;
                ue.LastName       = icr.LastName;
                ue.mobno1         = u.mobno1;
                ue.mobno2         = u.mobno2;
                ue.userRollstatus = "C";
                db.SaveChanges();
            }

            int custno = db.Users.Where(i => i.username == u.username).FirstOrDefault().srno;

            //er.ecom_CustomerId = custno;
            //db.ecom_RFID.Add(er);
            //db.SaveChanges();

            return(custno);
        }
Esempio n. 11
0
        public HttpResponseMessage RequestDistributorTags(HttpRequestMessage request, clsRequestDistributorTags crdt)
        {
            if (crdt == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            foreach (var item in crdt.Property1)
            {
                Distributor_Tag_Request dtr = new Distributor_Tag_Request();
                dtr.DistId         = item.DistId;
                dtr.Qty            = item.Qty;
                dtr.TagTypeID      = item.TagTypeID;
                dtr.RequestDate    = DateTime.Now;
                dtr.ApprovalStatus = "Pending";
                db.Distributor_Tag_Request.Add(dtr);
                db.SaveChanges();
            }



            return(request.CreateResponse(HttpStatusCode.OK, crdt));
        }
Esempio n. 12
0
        public IHttpActionResult UpdateUser(User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (user == null)
            {
                return(BadRequest());
            }
            else
            {
                try
                {
                    User utoupdate = db.Users.Where(o => o.srno == user.srno).FirstOrDefault();

                    utoupdate.FirstName    = user.FirstName;
                    utoupdate.LastName     = user.LastName;
                    utoupdate.BusinessName = user.BusinessName;
                    // db.Users.Find(id).username = user.username;
                    utoupdate.address   = user.address;
                    utoupdate.userEmail = user.userEmail;
                    utoupdate.mobno1    = user.mobno1;
                    utoupdate.mobno2    = user.mobno2;
                    utoupdate.status    = user.status;


                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 13
0
        public IHttpActionResult VerifyFastTagBooking(string RFID, string TollPlazaId)
        {
            User_Vehicle    vh  = db.User_Vehicle.Where(v => v.RFIDNumber == RFID).FirstOrDefault();
            User            vu  = db.Users.Where(u => u.srno == vh.userid).FirstOrDefault();
            TollPayWallet   tpw = db.TollPayWallets.Where(w => w.UserID == vh.userid).FirstOrDefault();
            DateTime        d   = DateTime.Now;
            UserTollTracker utt = db.UserTollTrackers.Where(ut => ut.TollPlazzaNo == Convert.ToInt32(TollPlazaId) && ut.VehicleNumber == vh.uservehicleRegNo && ut.tripDate <= d && ut.tripEndDate <= d).FirstOrDefault();

            utt.TollRemark = "Pass_" + d.ToString();
            db.SaveChanges();
            string smsmsg;

            smsmsg = "Dear " + vu.userEmail + " , TollPay.in U Just Passed. -" + TollPlazaId + ", TollAmt : " + utt.TollCost + "We be deducted";
            ns.sendsms("smsfrom", vu.mobno1, smsmsg);
            ns.sendemail(vu.userEmail, "", "TollPay.IN Notifications", smsmsg);
            bool res = true;

            return(Ok(res));
        }
Esempio n. 14
0
        public Tollcal GetTollPlaza(string source, string destination, string vehicletype, string journey)
        {
            bool    flag     = false;
            Tollcal response = new Tollcal();

            if (flag)
            {
                #region Sagar Code
                WebClient wb     = new WebClient();
                string    strurl = "http://tis.nhai.gov.in/UploadHandler.ashx?Up=3&Source=" + source + "&Destination=" + destination;

                string result = wb.DownloadString(strurl);
                //18.3313849,73.8525197$17.810312,73.971381$$113 km!2 hours 13 mins
                List <string>    tollplazza      = result.Split('$').ToList();
                DP_TPEntities    db              = new DP_TPEntities();
                List <TollPlaza> lsttollinrounte = new List <TollPlaza>();
                User_Trips       ut              = new User_Trips();
                ut.tripStartLocation = source;
                ut.tripEndLocation   = destination;
                Random random = new Random();
                int    numb   = random.Next(1, 31) % 31;
                if (numb != 0)
                {
                    ut.tripDate   = new DateTime(2019, 8, numb);
                    ut.tripStatus = "a";
                    ut.userid     = 1;
                }
                foreach (var item in tollplazza)
                {
                    if (item.Contains(','))
                    {
                        List <string> latlng = item.Split(',').ToList();
                        double        dlat   = Convert.ToDouble(latlng[0]);
                        lsttollinrounte.Add(db.TollPlazas.Where(l => l.lat == dlat).FirstOrDefault());
                    }
                }
                dynamic orderTotals = 0.0;
                //let orderTotals;
                //var orderTotals;
                List <TollPlazaRateByVehicleTypes> LstTPRBV = new List <TollPlazaRateByVehicleTypes>();

                switch (vehicletype)
                {
                case "Bus":
                    orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_bus_multi)).FirstOrDefault();
                    LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_bus_multi
                    }).ToList();
                    break;

                case "car":
                    if (journey == "multi")
                    {
                        orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_car_multi)).FirstOrDefault();
                        LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_car_multi
                        }).ToList();
                    }
                    else
                    {
                        orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => Convert.ToDecimal(item.rates_car_single))).FirstOrDefault();
                        LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_car_single
                        }).ToList();
                    }
                    break;

                case "sixaxle":
                    orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_four_six_axle_multi)).FirstOrDefault();
                    LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_four_six_axle_multi
                    }).ToList();
                    break;

                case "hcm":
                    orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_hcm_multi)).FirstOrDefault();
                    LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_hcm_multi
                    }).ToList();
                    break;

                case "lcv":
                    if (journey == "multi")
                    {
                        orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_lcv_multi)).FirstOrDefault();
                        LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_lcv_multi
                        }).ToList();
                    }
                    else
                    {
                        orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => Convert.ToDecimal(item.rates_lcv_single))).FirstOrDefault();
                        LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_lcv_single
                        }).ToList();
                    }

                    break;

                case "multaxle":
                    orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_multiaxle_multi)).FirstOrDefault();
                    LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_multiaxle_multi
                    }).ToList();
                    break;

                case "sevenaxle":
                    orderTotals = lsttollinrounte.GroupBy(i => 1).Select(g => g.Sum(item => item.rates_seven_plus_axle_multi)).FirstOrDefault();
                    LstTPRBV    = lsttollinrounte.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, lat = x.lat, lon = x.lon, Rate = x.rates_seven_plus_axle_multi
                    }).ToList();
                    break;

                default:
                    Console.WriteLine("Default case");
                    break;
                }

                // Tollcal response = new Tollcal();

                response.tollplaza = LstTPRBV;
                response.totalcost = (double)orderTotals;
                return(response);

                #endregion
            }
            else
            {
                string src  = source;
                string dest = destination;
                string vt   = vehicletype;
                string tt   = journey;
                //TollPlazaServiceSoapClient proxy = new TollPlazaServiceSoapClient();
                //List<string> names= proxy.AutoCompleteLocation("pu").ToList();
                WebClient wb     = new WebClient();
                string    result = string.Empty;
                try
                {
                    result = db.RouteTollsQueries.Where(r => r.src.Contains(src) && r.dest.Contains(dest)).FirstOrDefault().routetolls;
                }
                catch (Exception ex)
                {
                    if (result == string.Empty)
                    {
                        string strurl = "http://tis.nhai.gov.in/UploadHandler.ashx?Up=3&Source=" + src + "&Destination=" + dest;
                        result = wb.DownloadString(strurl);
                        db.RouteTollsQueries.Add(new RouteTollsQuery()
                        {
                            src = src, dest = dest, routeactive = "a", routetolls = result
                        });
                        db.SaveChanges();
                    }
                }


                List <getTripPrices_Result> lsttollplazz = db.getTripPrices(result).ToList();

                List <TollPlazaRateByVehicleTypes> LstTPRBV = new List <TollPlazaRateByVehicleTypes>();

                switch (vt)
                {
                case "Bus":

                    LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_bus_multi
                    }).ToList();
                    break;

                case "Car":
                    if (journey == "multi")
                    {
                        LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_car_multi
                        }).ToList();
                    }
                    else
                    {
                        LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_car_single
                        }).ToList();
                    }
                    break;

                case "Sixaxle":

                    LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_four_six_axle_multi
                    }).ToList();
                    break;

                case "HCM":

                    LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_hcm_multi
                    }).ToList();
                    break;

                case "LCV":
                    if (journey == "multi")
                    {
                        LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_lcv_multi
                        }).ToList();
                    }
                    else
                    {
                        LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                        {
                            id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_lcv_single
                        }).ToList();
                    }

                    break;

                case "Multaxle":

                    LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_multiaxle_multi
                    }).ToList();
                    break;

                case "Sevenaxle":

                    LstTPRBV = lsttollplazz.Select(x => new TollPlazaRateByVehicleTypes()
                    {
                        id = x.id, name = x.name, lat = x.lat, lon = x.lon, Rate = x.rates_seven_plus_axle_multi
                    }).ToList();
                    break;

                default:
                    // Console.WriteLine("Default case");
                    break;
                }

                List <TollRateCard> orderTotals = lsttollplazz
                                                  .GroupBy(i => 1)
                                                  .Select(g => new TollRateCard
                {
                    cnt = g.Count(),
                    rates_car_single              = g.Sum(item => item.rates_car_single),
                    rates_car_multi               = g.Sum(item => item.rates_car_multi),
                    rates_car_monthly             = g.Sum(item => item.rates_car_monthly),
                    rates_bus_multi               = g.Sum(item => item.rates_bus_multi),
                    rates_bus_monthly             = g.Sum(item => item.rates_bus_monthly),
                    rates_four_six_axle_single    = g.Sum(item => item.rates_four_six_axle_single),
                    rates_four_six_axle_multi     = g.Sum(item => item.rates_four_six_axle_multi),
                    rates_four_six_axle_monthly   = g.Sum(item => item.rates_four_six_axle_monthly),
                    rates_seven_plus_axle_single  = g.Sum(item => item.rates_seven_plus_axle_single),
                    rates_seven_plus_axle_multi   = g.Sum(item => item.rates_seven_plus_axle_multi),
                    rates_seven_plus_axle_monthly = g.Sum(item => item.rates_seven_plus_axle_monthly),
                    rates_hcm_single              = g.Sum(item => item.rates_hcm_single),
                    rates_hcm_multi               = g.Sum(item => item.rates_hcm_multi),
                    rates_hcm_monthly             = g.Sum(item => item.rates_hcm_monthly),
                    rates_lcv_single              = g.Sum(item => item.rates_lcv_single),
                    rates_lcv_multi               = g.Sum(item => item.rates_lcv_multi),
                    rates_lcv_monthly             = g.Sum(item => item.rates_lcv_monthly),
                    rates_multiaxle_single        = g.Sum(item => item.rates_multiaxle_single),
                    rates_multiaxle_multi         = g.Sum(item => item.rates_multiaxle_multi),
                    rates_multiaxle_monthly       = g.Sum(item => item.rates_multiaxle_monthly)
                }).ToList();


                double?tollamt = 0;
                switch (vt)
                {
                case "Car":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_car_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_car_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_car_monthly;
                    }
                    break;

                case "LCV":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_lcv_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_lcv_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_lcv_monthly;
                    }
                    break;

                case "Bus":
                    if (tt.ToLower() == "single")
                    {     //tollamt = orderTotals[0].rates_bus_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_bus_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_bus_monthly;
                    }
                    break;

                case "Multiaxle":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_multiaxle_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_multiaxle_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_multiaxle_monthly;
                    }
                    break;

                case "HCM":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_hcm_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_hcm_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_hcm_monthly;
                    }
                    break;

                case "Four_six_axle":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_four_six_axle_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_four_six_axle_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_four_six_axle_monthly;
                    }
                    break;

                case "Seven_plus_axle":
                    if (tt.ToLower() == "single")
                    {
                        tollamt = orderTotals[0].rates_seven_plus_axle_single;
                    }
                    else if (tt.ToLower() == "multi")
                    {
                        tollamt = orderTotals[0].rates_seven_plus_axle_multi;
                    }
                    else
                    {
                        tollamt = orderTotals[0].rates_seven_plus_axle_monthly;
                    }
                    break;

                default: break;
                }


                List <TollPlaza> lsttp = new List <TollPlaza>();
                foreach (var item in lsttollplazz)
                {
                    TollPlaza tp = new TollPlaza();
                    tp.id   = item.id;
                    tp.name = item.name;
                    tp.lat  = item.lat;
                    tp.lon  = item.lon;
                    lsttp.Add(tp);
                    //response.tollplaza.Add(tp);

                    #region mapcode
                    //public string name { get; set; }
                    //public Nullable<double> lat { get; set; }
                    //public Nullable<double> lon { get; set; }
                    //public Nullable<System.DateTime> fee_effective_date { get; set; }
                    //public Nullable<double> rates_car_single { get; set; }
                    //public Nullable<double> rates_car_multi { get; set; }
                    //public Nullable<double> rates_car_monthly { get; set; }
                    //public Nullable<double> rates_lcv_single { get; set; }
                    //public Nullable<double> rates_lcv_multi { get; set; }
                    //public Nullable<double> rates_lcv_monthly { get; set; }
                    //public Nullable<double> rates_bus_multi { get; set; }
                    //public Nullable<double> rates_bus_monthly { get; set; }
                    //public Nullable<double> rates_multiaxle_single { get; set; }
                    //public Nullable<double> rates_multiaxle_multi { get; set; }
                    //public Nullable<double> rates_multiaxle_monthly { get; set; }
                    //public Nullable<double> rates_hcm_single { get; set; }
                    //public Nullable<double> rates_hcm_multi { get; set; }
                    //public Nullable<double> rates_hcm_monthly { get; set; }
                    //public Nullable<double> rates_four_six_axle_single { get; set; }
                    //public Nullable<double> rates_four_six_axle_multi { get; set; }
                    //public Nullable<double> rates_four_six_axle_monthly { get; set; }
                    //public Nullable<double> rates_seven_plus_axle_single { get; set; }
                    //public Nullable<double> rates_seven_plus_axle_multi { get; set; }
                    //public Nullable<double> rates_seven_plus_axle_monthly { get; set; }

                    #endregion
                }
                response.tollplaza = LstTPRBV;
                response.totalcost = (double)tollamt;
                return(response);
            }
        }
Esempio n. 15
0
        public clsOTPValidationResponse MethodOTPValidationRequest(Bank_OTPValidationAPI bov)
        {
            DP_TPEntities db  = new DP_TPEntities();
            clsKeyValue   ckv = EncryptionLibrary.GetKeys();

            // bov.otpReferenceId = ckv.SessionID.Substring(0,19);

            try
            {
                //db.Bank_OTPValidationAPI.Add(bov);
                //db.SaveChanges();

                _clsNhaicchvalidateotprequest = new clsNhaicchvalidateotprequest();
                _clsNhaicchvalidateotprequest.NHAICCHValidateOTPRequest           = new Nhaicchvalidateotprequest();
                _clsNhaicchvalidateotprequest.NHAICCHValidateOTPRequest.SubHeader = new Subheader()
                {
                    channelId             = "DIGI",
                    requestUUID           = bov.otpReferenceId,
                    serviceRequestId      = "AE.NHAI.OTP.ESB.001",
                    serviceRequestVersion = "1.0"
                };
                var jsonString = JsonConvert.SerializeObject(bov);

                _clsNhaicchvalidateotprequest.NHAICCHValidateOTPRequest.NHAICCHValidateOTPRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);
                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/otp-validation");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);

                var requeststr = JsonConvert.SerializeObject(_clsNhaicchvalidateotprequest);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsNhaicchvalidateotpresponse json = JsonConvert.DeserializeObject <clsNhaicchvalidateotpresponse>(response.Content);

                string ser = string.Empty;
                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    ser = JsonConvert.SerializeObject(apierror);
                    covr.isOTPValidated = false;
                }
                else if (response.Content != string.Empty)
                {
                    ser  = EncryptionLibrary.decrypt(json.NHAICCHValidateOTPResponse.NHAICCHValidateOTPResponseBodyEncrypted, ckv.Key);
                    covr = JsonConvert.DeserializeObject <clsOTPValidationResponse>(ser);
                    //db.Bank_OTPValidationAPI.Where(o=>o.)
                    //db.Bank_OTPGenerationResponse.Add(covr);
                    //db.SaveChanges();
                }
                else
                {
                    ser = "Error";
                }



                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid       = ckv.SessionID,
                    request           = jsonString.ToString(),
                    requestEncrypted  = requeststr,
                    responseEncrypted = response.Content,
                    response          = JsonConvert.SerializeObject(covr)
                });
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                covr.isOTPValidated = false;
                return(covr);
            }

            return(covr);
        }
Esempio n. 16
0
        public Bank_OTPGenerationResponse MethodOTPGenerationRequest(Bank_OTPGenerate botpg)
        {
            Bank_OTPGenerationResponse bcdar = new Bank_OTPGenerationResponse();
            string vguid = ckv.SessionID;

            //botpg.otpReferenceId = vguid;

            db.Bank_OTPGenerate.Add(botpg);
            db.SaveChanges();


            NHAICCHGenerateOTPRequest           = new NHAICCHValidateOTPRequestBody();
            NHAICCHGenerateOTPRequest.SubHeader = new Subheader()
            {
                channelId             = "DIGI",
                requestUUID           = vguid,
                serviceRequestId      = "AE.NHAI.OTP.ESB.001",
                serviceRequestVersion = "1.0"
            };

            NHAICCHGenerateOTPRequest.NHAICCHGenerateOTPRequestBody = new Nhaicchgenerateotprequestbody()
            {
                mobileNumber   = Convert.ToString(botpg.mobileNumber),
                otpReferenceId = vguid
            };
            var jsonString = JsonConvert.SerializeObject(NHAICCHGenerateOTPRequest.NHAICCHGenerateOTPRequestBody);



            ClsNhaicchgenerateotprequest cnho = new ClsNhaicchgenerateotprequest();

            cnho.NHAICCHGenerateOTPRequest           = new Nhaicchgenerateotprequest();
            cnho.NHAICCHGenerateOTPRequest.SubHeader = NHAICCHGenerateOTPRequest.SubHeader;
            cnho.NHAICCHGenerateOTPRequest.NHAICCHGenerateOTPRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

            var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/otp-generation");

            client.Timeout = -1;
            var request = new RestRequest(Method.POST);

            request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
            request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", ckv.JWT);

            var requeststr = JsonConvert.SerializeObject(cnho);

            //Console.WriteLine("Request to API " + requeststr.ToString());
            request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

            APIException apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
            clsNhaicchgenerateotpresponse json = JsonConvert.DeserializeObject <clsNhaicchgenerateotpresponse>(response.Content);

            string ser = string.Empty;

            if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
            {
                ser             = JsonConvert.SerializeObject(apierror);
                bcdar.otpstatus = apierror.moreInformation + " | " + apierror.httpMessage;
            }
            else if (response.Content != string.Empty)
            {
                ser   = EncryptionLibrary.decrypt(json.NHAICCHGenerateOTPResponse.NHAICCHGenerateOTPResponseBodyEncrypted, ckv.Key);
                bcdar = JsonConvert.DeserializeObject <Bank_OTPGenerationResponse>(ser);
                db.Bank_OTPGenerationResponse.Add(bcdar);
                db.SaveChanges();
            }
            else
            {
                ser = "Error";
            }

            Console.WriteLine("API Plan Reponse" + ser);

            db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
            {
                RequestGuid       = ckv.SessionID,
                request           = jsonString.ToString(),
                subheaderMethod   = cnho.NHAICCHGenerateOTPRequest.SubHeader.serviceRequestId,
                requestEncrypted  = requeststr,
                responseEncrypted = response.Content,
                response          = JsonConvert.SerializeObject(json)
            });
            db.SaveChanges();

            return(bcdar);
        }
Esempio n. 17
0
        public Bank_RechargeResponse MethodRechargeWalletRequest(Bank_RechargeRequest brr)
        {
            DP_TPEntities      db    = new DP_TPEntities();
            clsKeyValue        ckv   = EncryptionLibrary.GetKeys();
            string             vguid = Convert.ToString(Guid.NewGuid());
            clsRechargerequest crg   = new clsRechargerequest();

            crg.RechargeRequest = new Rechargerequest();
            Bank_RechargeResponse brra = new Bank_RechargeResponse();

            try
            {
                crg.RechargeRequest.SubHeader = new Subheader()
                {
                    channelId             = "DIGI",
                    requestUUID           = vguid,
                    serviceRequestId      = "RECHARGE",
                    serviceRequestVersion = "1.0"
                };

                var jsonString = JsonConvert.SerializeObject(brr);



                crg.RechargeRequest.RechargeRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/recharge");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);

                var requeststr = JsonConvert.SerializeObject(crg);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException        apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsRechargeresponse json     = JsonConvert.DeserializeObject <clsRechargeresponse>(response.Content);

                string ser = string.Empty;
                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    ser = JsonConvert.SerializeObject(apierror);
                    brra.statusMessage = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    ser  = EncryptionLibrary.decrypt(json.RechargeResponse.RechargeResponseBodyEncrypted, ckv.Key);
                    brra = JsonConvert.DeserializeObject <Bank_RechargeResponse>(ser);
                    db.Bank_RechargeResponse.Add(brra);
                    db.SaveChanges();
                }
                else
                {
                    ser = "Error";
                }

                Console.WriteLine("API Plan Reponse" + ser);

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid       = ckv.SessionID,
                    request           = jsonString.ToString(),
                    subheaderMethod   = crg.RechargeRequest.SubHeader.serviceRequestId,
                    requestEncrypted  = requeststr,
                    responseEncrypted = response.Content,
                    response          = JsonConvert.SerializeObject(ser)
                });
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                brra.statusMessage = ex.Message;
                return(brra);
            }
            return(brra);
        }
Esempio n. 18
0
        public Bank_StatusEnquiryAPIResponse MethodClsStatusenquiryrequest(Bank_StatusEnquiryAPI bsea)
        {
            string vguid = ckv.SessionID;

            bsea.refId = bsea.sessionId; // ckv.SessionID;
            Bank_StatusEnquiryAPIResponse bcdar = new Bank_StatusEnquiryAPIResponse();
            clsStatusenquiryrequest       cser  = new clsStatusenquiryrequest();

            cser.StatusEnquiryRequest = new Statusenquiryrequest();

            try
            {
                db.Bank_StatusEnquiryAPI.Add(bsea);
                db.SaveChanges();

                Subheader sub = new Subheader()
                {
                    serviceRequestVersion = "1.0",
                    serviceRequestId      = "STATUS-ENQUIRY",
                    requestUUID           = bsea.refId,
                    channelId             = "DIGI"
                };
                cser.StatusEnquiryRequest.SubHeader = new Subheader();
                cser.StatusEnquiryRequest.SubHeader = sub;


                var jsonString = JsonConvert.SerializeObject(bsea);

                cser.StatusEnquiryRequest.StatusEnquiryRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/status-enquiry");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);

                var requeststr = JsonConvert.SerializeObject(cser);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException             apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsStatusenquiryresponse json     = JsonConvert.DeserializeObject <clsStatusenquiryresponse>(response.Content);
                string ser = string.Empty;
                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    ser = JsonConvert.SerializeObject(apierror);
                    bcdar.statuscode    = apierror.errorCode;
                    bcdar.statusmessage = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    ser   = EncryptionLibrary.decrypt(json.StatusEnquiryResponse.StatusEnquiryResponseBodyEncrypted, ckv.Key);
                    bcdar = JsonConvert.DeserializeObject <Bank_StatusEnquiryAPIResponse>(ser);
                    //update tollpay ecom and customer dudupe
                    if (bcdar.txnSeqNo.Length > 0 && bcdar.walletId.Length > 0)
                    {
                        //db.ecom_RFID.Where(x=>x.ecom_RFIDTagSrNo==bcdar.t)
                    }

                    db.Bank_StatusEnquiryAPIResponse.Add(bcdar);
                    db.SaveChanges();
                }
                else
                {//EncryptionLibrary.DecryptText(response.Content, akey);
                    ser = "Error";
                }

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid       = bsea.refId,
                    subheaderMethod   = cser.StatusEnquiryRequest.SubHeader.serviceRequestId,
                    Currenttime       = DateTime.Now,
                    request           = jsonString,
                    requestEncrypted  = requeststr,
                    responseEncrypted = response.Content,
                    response          = ser
                });
                db.SaveChanges();
                return(bcdar);
            }
            catch (Exception ex)
            {
                bcdar.statusmessage = ex.Message;
                return(bcdar);
            }
        }
        public Bank_RechargeStatusEnquiryResponse MethodclsWalletRequestStatus(Bank_RechargeStatusEnquiry brse)
        {
            DP_TPEntities db  = new DP_TPEntities();
            clsKeyValue   ckv = EncryptionLibrary.GetKeys();

            brse.uniquerefNo = ckv.SessionID.Substring(0, 19);

            db.Bank_RechargeStatusEnquiry.Add(brse);
            db.SaveChanges();

            ClsRStatusenquiryrequest Rser = new ClsRStatusenquiryrequest();

            Rser.StatusEnquiryRequest           = new RStatusenquiryrequest();
            Rser.StatusEnquiryRequest.SubHeader = new Subheader()
            {
                channelId             = "DIGI",
                requestUUID           = ckv.SessionID,
                serviceRequestId      = "RECHARGE-STATUS-ENQUIR",
                serviceRequestVersion = "1.0"
            };

            var jsonString = JsonConvert.SerializeObject(brse);

            Rser.StatusEnquiryRequest.StatusEnquiryRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);
            var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/enquiry");

            client.Timeout = -1;
            var request = new RestRequest(Method.POST);

            request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
            request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", ckv.JWT);

            var requeststr = JsonConvert.SerializeObject(Rser);

            request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

            APIException apierror          = JsonConvert.DeserializeObject <APIException>(response.Content);
            clsRStatusenquiryresponse json = JsonConvert.DeserializeObject <clsRStatusenquiryresponse>(response.Content);

            string ser = string.Empty;

            if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
            {
                ser = JsonConvert.SerializeObject(apierror);
                brser.statusMessage = apierror.moreInformation + " | " + apierror.httpMessage;;
                brser.statusCode    = apierror.httpCode.ToString();
            }
            else if (response.Content != string.Empty)
            {
                ser   = EncryptionLibrary.decrypt(json.StatusEnquiryResponse.StatusEnquiryResponseBodyEncrypted, ckv.Key);
                brser = JsonConvert.DeserializeObject <Bank_RechargeStatusEnquiryResponse>(ser);

                db.Bank_RechargeStatusEnquiryResponse.Add(brser);
                db.SaveChanges();
            }
            else
            {
                ser = "Error";
            }

            Console.WriteLine("API Plan Reponse" + ser);

            db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
            {
                RequestGuid       = ckv.SessionID,
                request           = jsonString.ToString(),
                subheaderMethod   = Rser.StatusEnquiryRequest.SubHeader.serviceRequestId,
                requestEncrypted  = requeststr,
                responseEncrypted = response.Content,
                response          = JsonConvert.SerializeObject(brser)
            });
            db.SaveChanges();

            return(brser);
        }
Esempio n. 20
0
        public Bank_CustDedupeAPIResponse MethodClsDeduperequest(Bank_CustDedupeAPI cd)
        {
            string vguid = ckv.SessionID;

            cd.sessionId = ckv.SessionID;
            cd.refId     = null;
            //cd.refId = ckv.SessionID; //RefID Should be blank
            Bank_CustDedupeAPIResponse bcdar = new Bank_CustDedupeAPIResponse();

            try
            {
                //var config = new MapperConfiguration(cfg => {
                //    cfg.CreateMap<Bank_CustDedupeAPI, CustomerDuplex>();
                //});
                //IMapper iMapper = config.CreateMapper();
                //var source = cd;
                //var destination = iMapper.Map<Bank_CustDedupeAPI, CustomerDuplex> (source);


                var    jsonString = JsonConvert.SerializeObject(cd);
                string DedupeRequestBodyEncrypted = EncryptionLibrary.encrypt(jsonString, ckv.Key);

                db.Bank_CustDedupeAPI.Add(cd);
                db.SaveChanges();

                var client = new RestClient(ckv.AxisSetuAPIURL + "/api/gateway/api/v1/fastag/customer-dedupe");
                client.Timeout = -1;
                var request = new RestRequest(Method.POST);
                request.AddHeader("X-IBM-Client-Id", ckv.XIBMClientId);
                request.AddHeader("X-IBM-Client-Secret", ckv.XIBMClientSecret);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Authorization", ckv.JWT);
                ClsEDeduperequest cldr = new ClsEDeduperequest();

                Subheader sd = new Subheader()
                {
                    channelId             = "DIGI",
                    requestUUID           = vguid,
                    serviceRequestId      = "Dedupe",
                    serviceRequestVersion = "1.0"
                };

                cldr.DedupeRequest           = new Deduperequest();
                cldr.DedupeRequest.SubHeader = new Subheader();
                cldr.DedupeRequest.SubHeader = sd;
                cldr.DedupeRequest.DedupeRequestBodyEncrypted = DedupeRequestBodyEncrypted;
                var requeststr = JsonConvert.SerializeObject(cldr);
                //Console.WriteLine("Request to API " + requeststr.ToString());
                request.AddParameter("application/json", requeststr.ToString(), ParameterType.RequestBody);
                IRestResponse response = client.Execute(request);
                //Console.WriteLine("AS Customer Dedupe Encrypted Reponse" + response.Content);

                APIException      apierror = JsonConvert.DeserializeObject <APIException>(response.Content);
                clsDeduperesponse json     = JsonConvert.DeserializeObject <clsDeduperesponse>(response.Content);

                if (apierror.httpCode != 200 && apierror.httpCode != 0) //503
                {
                    DedupeRequestBodyEncrypted = JsonConvert.SerializeObject(apierror);
                    bcdar.StatusCode           = apierror.errorCode;
                    bcdar.StatusMessage        = apierror.moreInformation + " | " + apierror.httpMessage;
                }
                else if (response.Content != string.Empty)
                {
                    DedupeRequestBodyEncrypted = EncryptionLibrary.decrypt(json.DedupeResponse.DedupeResponseBodyEncrypted, ckv.Key);
                    bcdar = JsonConvert.DeserializeObject <Bank_CustDedupeAPIResponse>(DedupeRequestBodyEncrypted);
                    db.Bank_CustDedupeAPIResponse.Add(bcdar);
                    db.SaveChanges();
                }
                else
                {//EncryptionLibrary.DecryptText(response.Content, akey);
                    DedupeRequestBodyEncrypted = "Error";
                }

                db.AxisSetuAPILoggers.Add(new AxisSetuAPILogger()
                {
                    RequestGuid     = vguid,
                    subheaderMethod = cldr.DedupeRequest.SubHeader.serviceRequestId,

                    Currenttime       = DateTime.Now,
                    request           = jsonString,
                    requestEncrypted  = requeststr,
                    response          = DedupeRequestBodyEncrypted,
                    responseEncrypted = response.Content
                });
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                bcdar.StatusMessage = ex.Message + " - " + ex.InnerException;
                return(bcdar);
                //db.AxisSetuAPILoggers.Where(r => r.RequestGuid == vguid).FirstOrDefault().response = ex.Message;
                //db.SaveChanges();
            }



            return(bcdar);
        }
        public IHttpActionResult PostPaymentGatewayResponse([FromBody] ebusbuzzpaymentResponseIndusWalletRecharge ebpriwr)
        {
            clsPayGateWayWalletRecharge c = new clsPayGateWayWalletRecharge();

            c.paymentGatewayResponse = ebpriwr.paymentGatewayResponse;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                db.PaymentGatewayResponses.Add(ebpriwr.paymentGatewayResponse);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }


            if (ebpriwr.paymentGatewayResponse.status == "success")
            {
                string strulr     = "https://fastag.gitechnology.in/indusindAPI/api/BC/Tag/recharge_wallet";
                string methodtype = "POST";
                string thetoken   = EncryptionsUtility.getheader(strulr, methodtype);
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                else
                {
                    ClsRechargeWallet objRechargeWallet = ebpriwr.objRechargeWallet;
                    ClsRechargeWallet objWallet         = new ClsRechargeWallet()
                    {
                        TransactionID = objRechargeWallet.TransactionID,
                        PaymentType   = objRechargeWallet.PaymentType,
                        //CustomerID = objRechargeWallet.CustomerID,
                        TagAccountNo       = objRechargeWallet.TagAccountNo,
                        MobileNumber       = objRechargeWallet.MobileNumber,
                        Amount             = objRechargeWallet.Amount,
                        RechargePercentage = objRechargeWallet.RechargePercentage,
                        TotalAmount        = objRechargeWallet.TotalAmount
                    };
                    string         serialInputWallet  = JsonConvert.SerializeObject(objWallet);
                    string         encryptedCityInput = EncryptionsUtility.AES_ENCRYPT(serialInputWallet, AESkey);
                    ClsRequestData objRequestData     = new ClsRequestData()
                    {
                        RequestData = encryptedCityInput
                    };
                    serialInputWallet = JsonConvert.SerializeObject(objRequestData);
                    Console.WriteLine(serialInputWallet);
                    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                    var client = new RestClient(strulr);
                    client.Timeout = -1;
                    var request = new RestRequest(Method.POST);
                    request.AddHeader("Authorization", thetoken);
                    request.AddHeader("Content-Type", "application/json");
                    request.AddParameter("application/json", serialInputWallet, ParameterType.RequestBody);
                    IRestResponse response = client.Execute(request);
                    Console.WriteLine(response.Content);

                    if (response == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        try
                        {
                            TokenResponse          json              = JsonConvert.DeserializeObject <TokenResponse>(response.Content);
                            var                    resData           = json.ResponseData;// this extracts the encrypted requesttoken;
                            string                 decResult         = EncryptionsUtility.AES_DECRYPT(resData, AESkey);
                            ResponseWalletRecharge objwalletrecharge = JsonConvert.DeserializeObject <ResponseWalletRecharge>(decResult);
                            c.objRespWalletResponse = objwalletrecharge;


                            return(Ok(c));
                        }
                        catch (Exception ex)
                        {
                            return(BadRequest(ex.Message));
                        }
                    }
                }
            }
            else
            {
                return(Ok(c));
            }
        }
Esempio n. 22
0
        public HttpResponseMessage PostUserimage([FromBody] Ima a)//or (Ima a) ,it works too
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError, "value");

            try
            {
                var bytes = Convert.FromBase64String(a.base64image);// a.base64image
                //or full path to file in temp location
                //var filePath = Path.GetTempFileName();

                // full path to file in current project location
                string filedir = "C:\\inetpub\\Websites\\tollpay.in\\docs\\"; // Path.Combine(Directory.GetCurrentDirectory(), "NewFolder");
                //Console.WriteLine(filedir);
                //Console.WriteLine(Directory.Exists(filedir));
                if (!Directory.Exists(filedir))
                { //check if the folder exists;
                    Directory.CreateDirectory(filedir);
                }
                string profilephoto = string.Empty;

                if (a.Imagetype == "Profile")
                {
                    profilephoto = a.userid + "_Pro.jpg";
                    int srno = Convert.ToInt32(a.userid);
                    db.Users.Where(b => b.srno == srno).FirstOrDefault().profilephoto = profilephoto;
                    db.SaveChanges();
                }
                else if (a.Imagetype == "DrivingLicence")
                {
                    profilephoto = a.userid + "_DL.jpg";
                    int    srno = Convert.ToInt32(a.userid);
                    string kdus = db.UserBankDetails.Where(b => b.userid == srno).FirstOrDefault().KYC_Documents_URLs;
                    kdus = kdus + "|" + profilephoto;
                    db.UserBankDetails.Where(b => b.userid == srno).FirstOrDefault().KYC_Documents_URLs = kdus;
                    db.SaveChanges();
                }
                else if (a.Imagetype == "Aadharcard")
                {
                    profilephoto = a.userid + "_AC.jpg";
                    int    srno = Convert.ToInt32(a.userid);
                    string kdus = db.UserBankDetails.Where(b => b.userid == srno).FirstOrDefault().KYC_Documents_URLs;
                    kdus = kdus + "|" + profilephoto;
                    db.UserBankDetails.Where(b => b.userid == srno).FirstOrDefault().KYC_Documents_URLs = kdus;
                    db.SaveChanges();
                }

                string file = Path.Combine(filedir, profilephoto);
                //Console.WriteLine(file);
                //Debug.WriteLine(File.Exists(file));


                if (bytes.Length > 0)
                {
                    using (var stream = new FileStream(file, FileMode.Create))
                    {
                        stream.Write(bytes, 0, bytes.Length);
                        stream.Flush();
                    }
                }


                string imgpath = db.AppKeys.Where(x => x.vKey == "ImagePath").FirstOrDefault().vvalue + profilephoto;

                response = Request.CreateResponse(HttpStatusCode.OK, imgpath);
                return(response);
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.OK, "Failed to upload" + ex.Message);
                return(response);
            }
        }
Esempio n. 23
0
        // this function is required to initiate payment
        public string initiatePaymentAPI(string aAmount, String Firstname, String Email, String Phone, String Productinfo, String Surl, String Furl, String Txnid)
        {
            env = ckv.easebuzzenv;
            string[] hashVarsSeq;
            string   hash_string = string.Empty;
            string   saltvalue   = ckv.easebuzzsalt;
            string   amount      = aAmount;
            string   firstname   = Firstname;
            string   email       = Email;
            string   phone       = Phone;
            string   productinfo = Productinfo;
            string   surl        = Surl;
            string   furl        = Furl;
            string   udf1        = "";
            string   udf2        = "";
            string   udf3        = "";
            string   udf4        = "";
            string   udf5        = "";

            // Generate transaction ID -> make sure this is unique for all transactions
            Random rnd     = new Random();
            string strHash = Easebuzz_Generatehash512(rnd.ToString() + DateTime.Now);

            //txnid = strHash.ToString().Substring(0, 20);
            txnid = Txnid;

            string paymentUrl = getURL();

            // Get configs from web config
            easebuzz_action_url = paymentUrl; // + "/pay/secure";

            // generate hash table
            System.Collections.Hashtable data = new System.Collections.Hashtable(); // adding values in gash table for data post
            data.Add("txnid", txnid);
            data.Add("key", ckv.easebuzzkey);
            string AmountForm = Convert.ToDecimal(amount.Trim()).ToString("g29");// eliminating trailing zeros

            amount = AmountForm;
            data.Add("amount", amount);
            data.Add("firstname", firstname.Trim());
            data.Add("email", email.Trim());
            data.Add("phone", phone.Trim());
            data.Add("productinfo", productinfo.Trim());
            data.Add("surl", surl.Trim());
            data.Add("furl", furl.Trim());
            data.Add("udf1", udf1.Trim());
            data.Add("udf2", udf2.Trim());
            data.Add("udf3", udf3.Trim());
            data.Add("udf4", udf4.Trim());
            data.Add("udf5", udf5.Trim());


            // generate hash
            hashVarsSeq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10".Split('|'); // spliting hash sequence from config
            hash_string = "";
            foreach (string hash_var in hashVarsSeq)
            {
                hash_string = hash_string + (data.ContainsKey(hash_var) ? data[hash_var].ToString() : "");
                hash_string = hash_string + '|';
            }
            hash_string += salt;                                            // appending SALT
            gen_hash     = Easebuzz_Generatehash512(hash_string).ToLower(); //generating hash
            data.Add("hash", gen_hash);
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var client  = new RestClient("https://pay.easebuzz.in/payment/initiateLink");
            var request = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            string postdata = "firstname=" + firstname + "&amount=" + amount + "&email=" + email + "&productinfo=FastagRecharge&phone=" + phone + "&surl=https://payment.tollpay.in/success.aspx&furl=https://payment.tollpay.in/success.aspx&txnid=" + txnid + "&key=" + ckv.easebuzzkey + "&udf1=&udf2=&udf3=&udf4=&udf4=&udf5=&udf6=&udf7=&udf8=&udf9=&udf10=&hash=" + gen_hash;

            request.AddParameter("application/x-www-form-urlencoded", postdata, ParameterType.RequestBody);
            IRestResponse   response = client.Execute(request);
            clsRespEaseBuzz obj      = JsonConvert.DeserializeObject <clsRespEaseBuzz>(response.Content);

            if (obj.status == 1)
            {
                DP_TPEntities          db  = new DP_TPEntities();
                PaymentGatewayResponse pgr = new PaymentGatewayResponse();
                pgr.firstname   = firstname;
                pgr.email       = email;
                pgr.CreatedDate = DateTime.Now;
                pgr.phone       = phone;
                pgr.amount      = Convert.ToDecimal(amount);
                pgr.txnid       = txnid;
                db.PaymentGatewayResponses.Add(pgr);
                db.SaveChanges();
                string strForm = easebuzz_action_url + obj.data;                     //Easebuzz_PreparePOSTForm(easebuzz_action_url, data);
                return(strForm);
            }
            else
            {
                DP_TPEntities          db  = new DP_TPEntities();
                PaymentGatewayResponse pgr = new PaymentGatewayResponse();
                pgr.firstname   = firstname;
                pgr.email       = email;
                pgr.CreatedDate = DateTime.Now;
                pgr.phone       = phone;
                pgr.amount      = Convert.ToDecimal(amount);
                pgr.txnid       = txnid;
                db.PaymentGatewayResponses.Add(pgr);
                db.SaveChanges();
                return(response.Content);
            }
        }