Beispiel #1
0
        public HttpResponseMessage SalesPersonTagReplacementRequest(HttpRequestMessage request, clsTagReplacement ctr)
        {
            if (ctr == null)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, ctr));
            }

            try
            {
                TagReplacementReq trr = new TagReplacementReq();

                trr.ReqDate      = DateTime.Now;
                trr.OldSrNo      = ctr.oldTagSrNo;
                trr.CustMobNo    = ctr.custMobNo;
                trr.VehicleNo    = ctr.vehicleNo;
                trr.VehicleClass = ctr.vehicleClass;
                Random rnd   = new Random();
                int    value = rnd.Next(100000, 999999);
                trr.OTP           = value;
                trr.Reason        = ctr.reason;
                trr.SalesPersonID = ctr.SalesPersonID;
                trr.DistID        = ctr.distID;
                db.TagReplacementReqs.Add(trr);
                db.SaveChanges();

                ecom_RFID ecr = db.ecom_RFID.Where(x => x.Serial_Number == ctr.oldTagSrNo).FirstOrDefault();
                ecr.ecom_RFIDStatus = "r";
                db.SaveChanges();
                ecom_RFID ecrn = db.ecom_RFID.Where(x => x.Serial_Number == ctr.newTagSrNo).FirstOrDefault();
                ecrn.ecom_CustomerMobNo     = ctr.custMobNo;
                ecrn.ecom_CustomerVehicleNo = ctr.vehicleNo;
                ecrn.ecom_RFIDStatus        = "a";
                db.SaveChanges();
                decimal amt = -100;
                DistributorCreditAccount dcr = db.DistributorCreditAccounts.FirstOrDefault();
                dcr.Amount      = Convert.ToDecimal("-100");
                dcr.DepositDate = DateTime.Now;
                string msg        = dcr.DepositedVia;
                string tagSrNoNew = ctr.newTagSrNo;
                int    len        = tagSrNoNew.Length;
                dcr.DepositedVia = "For tag replacement with serial no " + msg.Substring(len - 4);
                db.DistributorCreditAccounts.Add(dcr);

                db.SaveChanges();
                //update ecomRFID table row for old serial no. with status R
                //update ecomRFID table row for new serial no. with status A with customer's mob and vehicle no.
                //insert into DistributorCreditAccount a debit of -100 for tag replacement with srno.(last four character)
                trr.SrNo = trr.SrNo;
                return(request.CreateResponse(HttpStatusCode.OK, trr));
            }
            catch (Exception ex)
            {
                return(request.CreateResponse(HttpStatusCode.InternalServerError, ctr));
            }

            return(request.CreateResponse(HttpStatusCode.OK, ctr));
        }
Beispiel #2
0
        public HttpResponseMessage GetVehicleClassAndTagsDetailsByDistIDorVehicleID(HttpRequestMessage request, clsDIDorVID cdv)
        {
            if (cdv == null)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest, cdv));
            }

            try
            {
                int DID = Convert.ToInt32(cdv.DistID);
                if (String.IsNullOrEmpty(cdv.VehicleRegNo))
                {
                    return(request.CreateResponse(HttpStatusCode.OK, db.VTP_GetVehicleClassDetailsByDistID(DID)));
                }
                else
                {
                    ecom_RFID efrid = db.ecom_RFID.Where(x => x.ecom_CustomerVehicleNo == cdv.VehicleRegNo).FirstOrDefault();

                    string VehicleType = efrid.Vehicle_Type;
                    string custMobNo   = efrid.ecom_CustomerMobNo;
                    Random rnd         = new Random();
                    int    value       = rnd.Next(100000, 999999);

                    string            strmsg = "Tollpay OTP for tag replacement of VRN " + cdv.VehicleRegNo + " is: " + value.ToString();
                    TagReplacementReq tRR    = new TagReplacementReq();
                    tRR.SalesPersonID = Convert.ToInt32(cdv.DistID);
                    tRR.VehicleNo     = cdv.VehicleRegNo;
                    tRR.CustMobNo     = custMobNo;
                    tRR.OTP           = value;
                    tRR.ReqDate       = DateTime.Now;
                    db.TagReplacementReqs.Add(tRR);
                    db.SaveChanges();
                    ns.sendsms("Tollpay", custMobNo, strmsg);
                    clsVehicleTypePlusTag VTT = new clsVehicleTypePlusTag();
                    VTT.lstTags        = db.GetDistributorTags(cdv.DistID, VehicleType).ToList();
                    VTT.VehicleClassID = db.IndusInd_VehicleClassDetails.Where(v => v.VehicleType == VehicleType).FirstOrDefault().VehicleClassId.ToString();

                    return(request.CreateResponse(HttpStatusCode.OK, VTT));
                }
            }
            catch (Exception ex)
            {
                return(request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #3
0
        public void distributorFasttag(ResposeTagRootobject obj, ClsTollPayTagRegistraion ObjTPTagReg)
        {
            //check if tagsrno alredy exist update this record
            //IndusInd_TagRegistration itr=db.IndusInd_TagRegistration.Where(t=>t.)



            db.IndusInd_TagRegistration.Add(new IndusInd_TagRegistration()
            {
                DistributorId         = Convert.ToInt32(ObjTPTagReg.DistributorId),
                CustomerAccountType   = ObjTPTagReg.AccountType,
                CustomerMobileNo      = ObjTPTagReg.MobileNo,
                CustomerOrderNo       = ObjTPTagReg.OrderNo,
                CustomerPaymentAmount = Convert.ToDecimal(ObjTPTagReg.TagTotalAmount),
                //CustomerPaymentDetails= ObjTPTagReg.
                CustomerPaymentType       = ObjTPTagReg.PaymentType,
                CustomerShippingAddress   = JsonConvert.SerializeObject(ObjTPTagReg.ShippingAddress),
                CustomerVehicleTagDetails = JsonConvert.SerializeObject(ObjTPTagReg.VehicleInfo),
                OrderStatus   = obj.StatusCode,
                OrderDateTime = DateTime.Now,
            });
            db.SaveChanges();


            foreach (var vehicle in obj.VehicleInfo)
            {
                if (vehicle.StatusCode == "000")
                {
                    ecom_RFID er = db.ecom_RFID.Where(o => o.Serial_Number == vehicle.SerialNo).FirstOrDefault();
                    er.ecom_CustomerVehicleNo = vehicle.VechileNo;
                    er.ecom_CustomerId        = db.Users.Where(o => o.username == obj.MobileNo).FirstOrDefault().srno;
                    er.ecom_CustomerMobNo     = obj.MobileNo;
                    er.ecom_axis_WalletID     = ObjTPTagReg.MobileNo;
                    er.ecom_CustomerFName     = obj.OrderNo;
                    er.ecom_CreatedDate       = DateTime.Now;
                    if (ObjTPTagReg.DistributorId != null)
                    {
                        er.ecom_DistributionID = ObjTPTagReg.DistributorId;
                    }
                    er.ecom_isAllocated = true;
                    er.ecom_RFIDStatus  = "a";
                    db.SaveChanges();
                }
                else
                {
                    ecom_RFID er = db.ecom_RFID.Where(o => o.Serial_Number == vehicle.SerialNo).FirstOrDefault();
                    er.ecom_CustomerVehicleNo = vehicle.VechileNo;
                    er.ecom_CustomerId        = db.Users.Where(o => o.username == obj.MobileNo).FirstOrDefault().srno;
                    er.ecom_CustomerMobNo     = obj.MobileNo;
                    er.ecom_axis_WalletID     = ObjTPTagReg.MobileNo;
                    er.ecom_CustomerLName     = obj.OrderNo;
                    er.ecom_CreatedDate       = DateTime.Now;
                    if (ObjTPTagReg.DistributorId != null)
                    {
                        er.ecom_DistributionID = ObjTPTagReg.DistributorId;
                    }
                    er.ecom_isAllocated = true;
                    er.ecom_RFIDStatus  = vehicle.StatusCode;
                    db.SaveChanges();
                }
            }
        }
Beispiel #4
0
        public void allocateFastTag(Bank_CreateWalletAPI cw)
        {
            try
            {
                //Create User for TollPay
                //Update FastTage Vehicle Mapping
                //Update Distribi
                string cfasttag = cw.tagseq;

                ecom_RFID er = db.ecom_RFID.Where(p => p.ecom_RFIDTagSrNo == cfasttag).FirstOrDefault();
                User      u  = new User();
                u.mobno1    = cw.custmobilenumber;
                u.userEmail = cw.custemailId;
                u.address   = "FN=" + cw.custfirstname + "|LN=" + cw.custlastname + "|DoB=" + cw.custdob + "|PINCode=" + cw.custpincode;
                u.password  = Convert.ToString(GenerateRandomNo());
                u.status    = "a";
                u.username  = cw.custmobilenumber.Trim();
                er.ecom_CustomerVehicleNo = cw.vehregnumber;
                er.ecom_CustomerFName     = cw.custfirstname;
                er.ecom_CustomerLName     = cw.custlastname;
                er.ecom_CustomerMobNo     = cw.custmobilenumber.Trim();
                er.ecom_OTP                 = u.password;
                er.ecom_isAllocated         = true;
                er.ecom_CustomerVehicleType = cw.vehclass;
                er.ecom_CustomerIdentity    = "DoB=" + cw.custdob + "|PINCode=" + cw.custpincode;
                er.ecom_RFIDTagSrNo         = cw.tagseq;
                er.ecom_RFIDStatus          = "a";
                er.ecom_CustomerId          = createTollPayCustomer(u);
                db.SaveChanges();

                User_Vehicle vu = new User_Vehicle();
                vu.userid           = er.ecom_CustomerId;
                vu.RFIDNumber       = er.ecom_RFIDTagSrNo;
                vu.uservehicleRegNo = er.ecom_CustomerVehicleNo;
                vu.uservehicleType  = er.ecom_CustomerVehicleType;
                User_Vehicle uve = db.User_Vehicle.Where(i => i.uservehicleRegNo == vu.uservehicleRegNo).FirstOrDefault();
                if (uve == null)
                {
                    db.User_Vehicle.Add(vu);
                    db.SaveChanges();
                }
                else
                {
                    uve.userid           = er.ecom_CustomerId;
                    uve.RFIDNumber       = er.ecom_RFIDTagSrNo;
                    uve.uservehicleRegNo = er.ecom_CustomerVehicleNo;
                    uve.uservehicleType  = er.ecom_CustomerVehicleType;
                    db.SaveChanges();
                }



                TollPayWallet tpw = new TollPayWallet();
                tpw.UserID       = Convert.ToInt32(vu.userid);
                tpw.WalletAmount = 0;
                tpw.Status       = "a";
                tpw.ModifiedDate = DateTime.Now;
                TollPayWallet tpwe = db.TollPayWallets.Where(i => i.UserID == tpw.UserID).FirstOrDefault();
                if (tpwe == null)
                {
                    db.TollPayWallets.Add(tpw);
                    db.SaveChanges();
                }
                else
                {
                    tpwe.UserID       = Convert.ToInt32(vu.userid);
                    tpwe.WalletAmount = Convert.ToDecimal(cw.depositamt);
                    tpwe.Status       = "a";
                    tpwe.ModifiedDate = DateTime.Now;
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }