Esempio n. 1
0
 internal static transaction ADDTRANS(transaction OBJTRANS)
 {
     CHALOEntities db=new CHALOEntities();
        transaction OBJTRANSNEW =db.transactions.Add(OBJTRANS);
     db.SaveChanges();
     return OBJTRANSNEW;
 }
        public IHttpActionResult GetLogin(string name, string userid)
        {
            CHALOEntities db = new CHALOEntities();
            CH_USER objuser = new CH_USER();
            int pareseduser = Int32.Parse(userid);
            objuser = db.CH_USER.Where(s => s.USER_ID == pareseduser).FirstOrDefault<CH_USER>();

            objuser.USER_COUPONAPPLIED = true;

            objuser.USER_FIRSTNAME = name;
            db.Entry(objuser).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            List<CH_USER> list = db.Database.SqlQuery<CH_USER>("select * from ch_user where USER_ID="+ userid +" and user_status=1").ToList();

            // List<LOCATION> users = new List<LOCATION>();

            //return CreatedAtRoute("DefaultApi", new { id = users[0].USER_ID }, users);
            //CH_USER cH_USER = db.CH_USER.Find(userid);
            //if (cH_USER == null)
            //{
            //    return NotFound();
            //}

            return Ok(list);
        }
Esempio n. 3
0
 internal static WALLETTRANSACTION ADDWALLETTRANS(WALLETTRANSACTION OBJTRANS)
 {
     CHALOEntities db=new CHALOEntities();
     WALLETTRANSACTION OBJTRANSNEW=db.WALLETTRANSACTIONS.Add(OBJTRANS);
     db.SaveChanges();
     return OBJTRANSNEW;
 }
        public IHttpActionResult Gethistory(string userid)
        {
            CHALOEntities db = new CHALOEntities();

            List<WALLET> list = db.Database.SqlQuery<WALLET>("select * from wallet where wallet_userid="+ userid +"").ToList();

            return Ok(list);
        }
        public IHttpActionResult Gethistory(string userid,string tripid)
        {
            CHALOEntities db=new CHALOEntities();

            List<TRIPHISTORYENTITY> list = db.Database.SqlQuery<TRIPHISTORYENTITY>("exec USP_TRIPHISTORY @OPERATION='GETALLTRIPSBYUSERID',@USER_ID='"+ userid +"'").ToList();

            return Ok(list);
        }
        public IHttpActionResult GetLogin(string subject, string desc, string userid)
        {
            CHALOEntities db = new CHALOEntities();
            SUPPORT objuser = new SUPPORT();
            objuser.SUPPORT_CREATEDBY = 1;
            objuser.SUPPORT_CREATEDDATE = common.getdate();
            objuser.SUPPORT_DESCRIPTION = desc;
            objuser.SUPPORT_MODIFIEDBY = 1;
            objuser.SUPPORT_SUBJECT = subject;
            objuser.SUPPORT_USERID = Convert.ToInt32(userid);

            objuser = db.SUPPORTs.Add(objuser);
            db.SaveChanges();

            return Ok(objuser);
        }
        public IHttpActionResult Gethistory(string mobile)
        {
            CHALOEntities db = new CHALOEntities();
            List<DRIVER> users = db.Database.SqlQuery<DRIVER>("select * from drivers where driver_mobile='" + mobile.Trim() + "'").ToList();

            if (users.Count > 0)
            {
                int number = common.generateotp();
                bool statusnew = common.sendmessage("Hello Chalo driver, your OTP is "+ number +"",mobile.Trim());
                return Json(new { otp = number });
            }
            else
            {
                return Ok(users);
            }
        }
Esempio n. 8
0
 internal static USERCOUPON addusercoupon(int userid)
 {
     USERCOUPON obj = new USERCOUPON();
     obj.COUPON_USERID = userid;
     //freehunderdwallet
     obj.COUPON_TYPE = 6;
     obj.COUPON_STATUS = 1;
     obj.COUPON_MONEY = 100;
     obj.COUPON_CREATEDBY = 1;
     obj.COUPON_CREATEDDATE = common.getdate();
     obj.COUPON_MODIFIEDBY = 1;
     obj.COUPON_MODIFIEDDATE = common.getdate();
     var dbcontext=new CHALOEntities();
       USERCOUPON objcoupon=dbcontext.USERCOUPONS.Add(obj);
                 dbcontext.SaveChanges();
     return obj;
 }
        //    public IHttpActionResult checkcoupon(string userid)
        //    {
        //        CHALOEntities db = new CHALOEntities();
        //        CH_USER objuser = new CH_USER();
        //        List<USERCOUPON> list = db.Database.SqlQuery<USERCOUPON>("select * from usercoupons where coupon_userid='" + userid + "' ").ToList();
        //        return Ok(list);
        //    }
        public IHttpActionResult GetLogin(string userid)
        {
            CHALOEntities db = new CHALOEntities();
            CH_USER objuser = new CH_USER();

            List<USERCOUPON> list = db.Database.SqlQuery<USERCOUPON>("select * from usercoupons where coupon_userid=" + userid + " and coupon_status=1").ToList();

            // List<LOCATION> users = new List<LOCATION>();

            //return CreatedAtRoute("DefaultApi", new { id = users[0].USER_ID }, users);
            //CH_USER cH_USER = db.CH_USER.Find(userid);
            //if (cH_USER == null)
            //{
            //    return NotFound();
            //}

            return Ok(list);
        }
        public IEnumerable<LOCATIONENTITY> Get(string type,string from,string city)
        {
            CHALOEntities db = new CHALOEntities();
            // List<LOCATION> list = new List<LOCATION>();
            List<LOCATIONENTITY> list = new List<LOCATIONENTITY>();
            if(type=="city")
            {
            list = db.Database.SqlQuery<LOCATIONENTITY>("EXEC USP_GETLOCS @OPERATION='CITIES'").ToList();
            }
            else if(type=="from")
            {
                list = db.Database.SqlQuery<LOCATIONENTITY>("EXEC USP_GETLOCS @OPERATION='FROMLOCATIONS',@CITY_NAME='"+ city +"'").ToList();
            }
            else
            {
                list = db.Database.SqlQuery<LOCATIONENTITY>("EXEC USP_GETLOCS @OPERATION='TOLOCATIONS',@CITY_NAME='" + city + "',@FROMLOCATION='"+ from +"'").ToList();
            }
            // List<LOCATION> list = db.LOCATIONS.Where(c => c.LOCATION_STATUS==1).ToList().OrderBy(c=>c.LOCATION_NAME).ToList();

            return list;
        }
        public IHttpActionResult Gethistory(string email,string mobile)
        {
            CHALOEntities db = new CHALOEntities();
            List<CH_USER> list = new List<CH_USER>();
            if (email!="")
            {
                list = db.Database.SqlQuery<CH_USER>("select * from ch_user where user_emailid='" + email + "' or user_mobile='" + mobile + "'").ToList();
            }
            else if(mobile!="")
            {
                list = db.Database.SqlQuery<CH_USER>("select * from ch_user where user_mobile='" + mobile + "'").ToList();
            }
            if (list.Count>0)
            {
                CH_USER objuser = new CH_USER();
                int pareseduser = (list[0].USER_ID);
                objuser = db.CH_USER.Where(s => s.USER_ID == pareseduser).FirstOrDefault<CH_USER>();
                objuser.USER_COUPONAPPLIED = true;
                string pasword = common.CreatePassword(5);
                objuser.USER_PASSWORD = encryptdecrypt.Encrypt(pasword);
                db.Entry(objuser).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                bool status=common.sendmessage("As per your request, Your CHALO password has been changed. "+ pasword +" is your new password,Happily CHALO. ",""+ list[0].USER_MOBILE +"");
                StreamReader reader = new StreamReader(Path.Combine(System.Web.HttpContext.Current.Server.MapPath(@"~/Emails/forgotemail.html")));
                string readFile = reader.ReadToEnd();
                string myString = "";
                myString = readFile;
                myString = myString.Replace("$$EMAIL$$", list[0].USER_EMAILID);
                myString = myString.Replace("$$PASSWORD$$", pasword);
                bool statusemail = common.sendemail(myString,"Your CHALO password has been reset","*****@*****.**",list[0].USER_EMAILID);

            }
            else
            {

            }
            return Ok(list);
        }
        public IHttpActionResult Gethistory(string tripid,string userid)
        {
            int? user = Int32.Parse(userid);
            CHALOEntities db = new CHALOEntities();
            List<USERTRIP> list = new List<USERTRIP>();
            int trip = Int32.Parse(tripid);
            USERTRIP objtrip = new USERTRIP();
            objtrip = db.USERTRIPS.Where(s => s.USERTRIP_ID == trip).FirstOrDefault<USERTRIP>();
            objtrip.USERTRIP_STATUS = 4;
            db.Entry(objtrip).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            List<CH_USER>users = db.Database.SqlQuery<CH_USER>("select * from ch_user where user_id="+ userid +"").ToList();

            List<TRIPHISTORYENTITY> listtripd = db.Database.SqlQuery<TRIPHISTORYENTITY>("exec USP_TRIPHISTORY @OPERATION='GETALLTRIPSBYTRIPID',@TRIP_ID=" + tripid + "").ToList();
            bool statusnew = common.sendmessage("As per your request, Your booking has been cancelled. Vehicle number:" + listtripd[0].VEHICLENUMBER + ", Driver name:" + listtripd[0].DRIVERNAME + " (" + listtripd[0].DRIVERMOBILE + ") @" + listtripd[0].USERTRIP_PICKUPACTUALTIME + ". For any assistance call us at 9900036467 or [email protected]", users[0].USER_MOBILE);
            PAYMENTHISTORY objhistory = new PAYMENTHISTORY();
            objhistory = db.PAYMENTHISTORies.Where(s => s.PAYMENTHISTORY_USERTRIPID == trip).FirstOrDefault<PAYMENTHISTORY>();
            string message = "";
            if (objhistory.PAYMENTTYPE_ID==1 || objhistory.PAYMENTTYPE_ID == 3)
            {
                message = "Your Booking order has been cancelled";
                decimal? price = objhistory.PAYMENTTYPE_AMOUNTPAID;
                transaction objtrans = new transaction();
                objtrans.TRANS_MODE = 1;
                objtrans.TRANS_CREDIT = true;
                objtrans.TRANS_DEBIT = false;
                objtrans.TRANS_AMOUNT = price;
                objtrans.TRANS_CREATEDBY = user;
                objtrans.TRANS_CRETEATEDDATE = common.getdate();
                objtrans.TRANS_MODENAME = "wallet";
                objtrans.TRANS_MODIFIEDBY = user;
                objtrans.TRANS_MODIFIEDDATE = common.getdate();
                objtrans.TRANS_NAME = "Cancelled amount retrn back";
                objtrans.TRANS_STATUS = 1;
                objtrans.TRANS_USERID = user;
                objtrans = db.transactions.Add(objtrans);
                db.SaveChanges();
                WALLET objwallet = new WALLET();
                objwallet = db.WALLETs.Where(s => s.WALLET_USERID == user).FirstOrDefault<WALLET>();

                WALLETTRANSACTION objwtrans = new WALLETTRANSACTION();
                objwtrans.TRANS_COMMENT = "Cancelled amount return back";
                objwtrans.TRANS_CREATEDBY = user;
                objwtrans.TRANS_CREATEDDATE = common.getdate();
                objwtrans.TRANS_MODIFIEDBY = user;
                objwtrans.TRANS_MODIFIEDDATE = common.getdate();
                objwtrans.TRANS_STATUS = 1;
                objwtrans.TRANS_ID = objtrans.TRANS_ID;
                objwtrans.TRANS_WALLETID = objwallet.WALLET_ID;
                objwtrans.TRANS_WALLETTYPE = 4;
                objwtrans = db.WALLETTRANSACTIONS.Add(objwtrans);
                db.SaveChanges();
                db.Entry(objwallet).State = System.Data.Entity.EntityState.Modified;
                objwallet.WALLET_AVAILABLEMONEY = objwallet.WALLET_AVAILABLEMONEY + price;
                objwallet.WALLET_MODIFIEDBY = user;
                objwallet.WALLET_MODIFIEDDATE = common.getdate();
                db.SaveChanges();
                List<USERTRIP> result = db.Database.SqlQuery<USERTRIP>("select * from usertrips where usertrip_id="+ tripid +"").ToList();
                NOOFSEAT objseats = new NOOFSEAT();
                int? trip_id = result[0].USERTRIP_TRIPID;
                objseats = db.NOOFSEATS.Where(s => s.SEAT_TRIP_ID == trip_id).FirstOrDefault<NOOFSEAT>();
                objseats.SEAT_AVAILABLESEATS = objseats.SEAT_AVAILABLESEATS + 1;
                db.Entry(objseats).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

            }
            else
            {
                message = "Your Booking order has been cancelled";
            }

            return Json(new { Message = message });
        }
 public IHttpActionResult GETVEHICLES(string trip, string from, string to)
 {
     var entityContext = new CHALOEntities();
     List<TRIPTEMP> listvehicle = entityContext.Database.SqlQuery<TRIPTEMP>("exec [USP_GETVEHICLEBYTRIP] @DROPLOCATION='" + to + "',@PICKUPLOCATION='" + from + "',@TRIP_ID='"+ trip +"'").ToList();
     return Ok(listvehicle);
 }
        public IHttpActionResult PostBookinginfo(bookinglist obj)
        {
            //  List<USERTRIP> list = new List<USERTRIP>();

            CHALOEntities db = new CHALOEntities();
            List<NOOFSEAT> NOOFSEATS = new List<NOOFSEAT>();
            List<WALLET> objwallet = new List<WALLET>();
            string usertrip = "";
            // List<LOCATION> users = new List<LOCATION>();
            try
            {

                NOOFSEATS = db.Database.SqlQuery<NOOFSEAT>("EXEC noofseatsavailability @TRIP_ID='" + obj.trip_id + "'").ToList();

                if (NOOFSEATS.Count > 0)
                {
                    if (obj.paymenttype == "1")
                    {
                        objwallet = db.Database.SqlQuery<WALLET>("EXEC CHECKWALLETAMOUNT @USER_ID='" + obj.userid + "'").ToList();
                        if (objwallet[0].WALLET_AVAILABLEMONEY >= obj.totalamount)
                        {

                            usertrip=bookride(obj,objwallet[0].WALLET_ID);
                            try
                            {
                            string mobilenumber =usertrip.Split('$')[1];
                           List<CH_USER> users = db.Database.SqlQuery<CH_USER>("select * from ch_user where user_id='" + obj.userid + "' and user_status=1").ToList();
                            bool statusnew = common.sendmessage("Thank you for choosing CHALO. Your booking has been confirmed. Vehicle number:"+ obj.vehicle_number +", Driver name:"+ obj.driver_name +" ("+ mobilenumber +"). Please reach Pickup point("+ obj.fromlocationname +") 5 minutes before. Your pick up time is "+ obj.fromactualreachtime +". For any assistance call us at 9900036467 or [email protected]",users[0].USER_MOBILE);
                            }
                            catch(Exception ex)
                            {

                            }
                                //StreamReader reader = new StreamReader(Path.Combine(System.Web.HttpContext.Current.Server.MapPath(@"~/Emails/registeremail.html")));
                            //string readFile = reader.ReadToEnd();
                            //string myString = "";
                            //myString = readFile;
                            //myString = myString.Replace("$$NAME$$", objuser.USER_FIRSTNAME);
                            //myString = myString.Replace("$$CODE$$", objusercoupon.COUPON_NAME);
                            //bool statusemail = common.sendemail(myString, "Welcome to CHALO", "*****@*****.**", objuser.USER_EMAILID);

                            //return Ok(result);
                            return Json(new { Success = usertrip });
                        }
                        else
                        {
                            return Json(new { nowallet = "you have " + objwallet[0].WALLET_AVAILABLEMONEY + " RS in your wallet which is not sufficient to book your cab" });
                        }
                    }
                    else if(obj.paymenttype=="2")
                    {
                         usertrip = bookride(obj,0);
                        try
                        {
                            string mobilenumber = usertrip.Split('$')[1];
                            List<CH_USER> users = db.Database.SqlQuery<CH_USER>("select * from ch_user where user_id='" + obj.userid + "' and user_status=1").ToList();
                            bool statusnew = common.sendmessage("Thank you for choosing CHALO. Your booking has been confirmed. Vehicle number:" + obj.vehicle_number + ", Driver name:" + obj.driver_name + " (" + mobilenumber + "). Please reach Pickup point(" + obj.fromlocationname + ") 5 minutes before. Your pick up time is " + obj.fromactualreachtime + ". For any assistance call us at 9900036467 or [email protected]", users[0].USER_MOBILE);
                        }
                        catch (Exception ex)
                        {

                        }
                        return Json(new { Success = usertrip });
                    }
                    else
                    {
                        return Json(new { errorthing = "error" });
                    }
                }
                else
                {
                    return Json(new { noseats = "seatsover" });
                }
                // users = db.LOCATIONS.ToList();
            }
            catch (Exception ex)
            {
                return Json(new { errorthing = "error" });
            }
        }
        internal string bookride(bookinglist obj,int walletid)
        {
            CHALOEntities db = new CHALOEntities();
            List<bookeddetails> USERTRIPs = new List<bookeddetails>();
            string result = "";
               // List<USERTRIP> USERTRIPs = new List<USERTRIP>();
            try
            {
                string proc = "EXEC USP_BOOKCAB @USER_ID='" + obj.userid + "' ,@USERTRIP_TRIPID='" + obj.trip_id + "',@USERTRIP_PICKUPLOC='" + obj.fromllid + "',@USERTRIP_DROPLOC='" + obj.tollid + "',@USERTRIP_VIA='" + obj.VIA + "',@USERTRIP_ESTIMATEDDURATION='" + obj.duration + "',@USERTRIP_ACTUALDURATION='" + obj.duration + "' ,@USERTRIP_DISTANCE='" + obj.DISTANCE + "',@USERTRIP_ACTUALAMOUNT='" + obj.COST + "',@USERTRIP_DISCOUNT='" + obj.discount + "',@USERTRIP_TOTALAMOUNT='" + obj.totalamount + "',@USERTRIP_STATUS=1,@USERTRIP_APPLIEDCOUPON='" + obj.appliedcoupon + "',@TRANS_STATUS=1 ,@PAYMENTTYPE_ID='" + obj.paymenttype + "' ,@APPLIEDCOUPONNAME ='" + obj.APPLIEDCOUPONNAME + "',@ISONETIME='" + obj.ISONETIME + "',@OPERATION ='BOOKCAB',@usertrip_pickupavergetime='" + obj.fromaveragereachtimenormal + "',@usertrip_pickupactualtime='" + obj.fromactualreachtimenormal + "',@usertrip_dropaveragetime='" + obj.toactualreachtimenormal + "',@usertrip_dropactualtime='" + obj.toactualreachtimenormal + "'";
                USERTRIPs = db.Database.SqlQuery<bookeddetails>("EXEC USP_BOOKCAB @USER_ID='" + obj.userid + "' ,@USERTRIP_TRIPID='" + obj.trip_id + "',@USERTRIP_PICKUPLOC='" + obj.fromllid + "',@USERTRIP_DROPLOC='" + obj.tollid + "',@USERTRIP_VIA='" + obj.VIA + "',@USERTRIP_ESTIMATEDDURATION='" + obj.duration + "',@USERTRIP_ACTUALDURATION='" + obj.duration + "' ,@USERTRIP_DISTANCE='" + obj.DISTANCE + "',@USERTRIP_ACTUALAMOUNT='" + obj.COST + "',@USERTRIP_DISCOUNT='" + obj.discount + "',@USERTRIP_TOTALAMOUNT='" + obj.totalamount + "',@USERTRIP_STATUS=1,@USERTRIP_APPLIEDCOUPON='" + obj.appliedcoupon + "',@TRANS_STATUS=1 ,@PAYMENTTYPE_ID='" + obj.paymenttype + "' ,@APPLIEDCOUPONNAME ='" + obj.APPLIEDCOUPONNAME + "',@ISONETIME='" + obj.ISONETIME + "',@OPERATION ='BOOKCAB',@usertrip_pickupavergetime='"+ obj.fromaveragereachtimenormal + "',@usertrip_pickupactualtime='"+ obj.fromactualreachtimenormal + "',@usertrip_dropaveragetime='"+ obj.toactualreachtimenormal + "',@usertrip_dropactualtime='"+ obj.toactualreachtimenormal +"',@WALLET_ID="+ walletid +"").ToList();
                if(USERTRIPs.Count>0)
                {
                    result = USERTRIPs[0].SUCCESS;
                }
            }
            catch (Exception ex)
            {

            }
            return result;
        }
 public IHttpActionResult GETPASSENGERS(string tripid)
 {
     var entityContext = new CHALOEntities();
     List<PASSENGERSENTITY> passengers = entityContext.Database.SqlQuery<PASSENGERSENTITY>("exec [USP_DRIVERSAPP] @TRIP_ID="+ tripid + ",@OPERATION='PASSENGERS'").ToList();
     return Ok(passengers);
 }
 public IHttpActionResult GETVEHICLES(string from, string to)
 {
     var entityContext = new CHALOEntities();
     List<TRIPTEMP> smdetails = entityContext.Database.SqlQuery<TRIPTEMP>("exec USP_SEARCHVEHICLES @DROPLOCATION='" + to + "',@PICKUPLOCATION='" + from + "'").ToList();
     return Ok(smdetails);
 }
Esempio n. 18
0
        internal static bool FIRSTUSER100RS(string USERID,string COUPONID,string couponuserid,int refcouponid)
        {
            int COUPONUSERID =1 ;
             if(COUPONID==null || COUPONID=="")
            {
                 COUPONUSERID= 1;
               }
             else
             {
                 COUPONUSERID = Convert.ToInt32(couponuserid);
             }

            CHALOEntities db=new CHALOEntities();
            //coupon applied status
            CH_USER objuser=new CH_USER();
            int pareseduser=Int32.Parse(USERID);
            objuser = db.Database.SqlQuery<CH_USER>("select top 1 * from ch_user where user_id='" + pareseduser + "' and user_status=1").FirstOrDefault<CH_USER>();

            objuser.USER_COUPONAPPLIED=true;

                objuser.USER_REFEREDBY=COUPONUSERID;
               db.Entry(objuser).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            //CREATING WALLET FOR USER
            WALLET OBJWALLET=new WALLET();
            OBJWALLET.WALLET_CREATEDBY=1;
            OBJWALLET.WALLET_CREATEDDATE=getdate();
            OBJWALLET.WALLET_MODIFIEDBY=1;
            OBJWALLET.WALLET_MODIFIEDDATE=getdate();
            OBJWALLET.WALLET_STATUS=1;
            OBJWALLET.WALLET_USERID=Int32.Parse(USERID);
            OBJWALLET.WALLET_AVAILABLEMONEY=decimal.Parse("0.00");

            OBJWALLET =db.WALLETs.Add(OBJWALLET);
            db.SaveChanges();

            //appliedcouponstableinsert

            APPLIEDCOUPON objcoupon=new APPLIEDCOUPON();

            objcoupon.APPLIED_REFERRALBONUS = false;
            if(COUPONID==null || COUPONID=="")
            {
                objcoupon.APPLIED_COUPONID = 101;
            objcoupon.APPLIED_COUPONNAME="CHALO-100";
                objcoupon.APPLIED_ADMINCOUPON=true;
                objcoupon.APPLIED_USERCOUPON=false;
                }
            else
            {
                objcoupon.APPLIED_COUPONID = refcouponid;

            objcoupon.APPLIED_COUPONNAME=COUPONID;
                  objcoupon.APPLIED_ADMINCOUPON=false;
                objcoupon.APPLIED_USERCOUPON=true;
              }
            objcoupon.APPLIED_CREATEDDATE=getdate();
                objcoupon.APPLIED_CREATEDBY=1;
            objcoupon.APPLIED_MODIFIEDBY=1;
            objcoupon.APPLIED_MODIFIEDDATE=getdate();
            objcoupon.APPLIED_ONETIME=true;
            objcoupon.APPLIED_STATUS=1;

                 objcoupon.APPLIED_USERID= COUPONUSERID;

               objcoupon=db.APPLIEDCOUPONS.Add(objcoupon);
            db.SaveChanges();

               // //l00rswalletdeposittransaction
               // transaction OBJTRANS=new transaction();
               // OBJTRANS.TRANS_AMOUNT=decimal.Parse("100.00");
               // OBJTRANS.TRANS_CREATEDBY=1;
               // OBJTRANS.TRANS_CRETEATEDDATE=getdate();
               // OBJTRANS.TRANS_MODE=1;
               // OBJTRANS.TRANS_MODENAME="wallet";
               // OBJTRANS.TRANS_MODIFIEDBY=1;
               // OBJTRANS.TRANS_MODIFIEDDATE=getdate();
               // OBJTRANS.TRANS_NAME="CHALO WALLET FIRST TIME USER 100RS";
               //OBJTRANS.TRANS_STATUS=1;
               //OBJTRANS.TRANS_USERID = Convert.ToInt32(USERID);
               //OBJTRANS.TRANS_CREDIT = true;
               //OBJTRANS.TRANS_DEBIT = false;

               // OBJTRANS=ADDTRANS(OBJTRANS);
               // db.SaveChanges();

            //
            //ADDING WALLET TRANS

               // WALLETTRANSACTION OBJWALLETTRANS=new WALLETTRANSACTION();
               // OBJWALLETTRANS.TRANS_COMMENT="CHALOWALLET FIRSTTIME USER 100";
               // OBJWALLETTRANS.TRANS_COUPONAPPLIEDID=objcoupon.APPLIED_ID;
               // OBJWALLETTRANS.TRANS_CREATEDBY=1;
               // OBJWALLETTRANS.TRANS_CREATEDDATE=getdate();
               // OBJWALLETTRANS.TRANS_ID=OBJTRANS.TRANS_ID;
               // OBJWALLETTRANS.TRANS_MODIFIEDBY=1;
               // OBJWALLETTRANS.TRANS_MODIFIEDDATE=getdate();
               // OBJWALLETTRANS.TRANS_STATUS=1;
               //OBJWALLETTRANS.TRANS_TRANSACTIONID=OBJTRANS.TRANS_ID;
               // OBJWALLETTRANS.TRANS_WALLETID=OBJWALLET.WALLET_ID;
               // OBJWALLETTRANS.TRANS_WALLETSTATUS=1;
               // OBJWALLETTRANS.TRANS_WALLETTYPE=1;
               //OBJWALLETTRANS=db.WALLETTRANSACTIONS.Add(OBJWALLETTRANS);
               //  db.SaveChanges();

            //adding 100 to wallet
            // OBJWALLET = db.WALLETs.Where(s => s.WALLET_ID == OBJWALLET.WALLET_ID).FirstOrDefault<WALLET>();
            //OBJWALLET.WALLET_AVAILABLEMONEY=decimal.Parse("100.00");
            // db.Entry(OBJWALLET).State = System.Data.Entity.EntityState.Modified;
            // db.SaveChanges();

            //addingwallettoreferredperson
            if(couponuserid!=null && couponuserid!="")
            {
                int cid = Int32.Parse(couponuserid);
                //appliedcouponstableinsert

                APPLIEDCOUPON objcouponref = new APPLIEDCOUPON();
                objcouponref.APPLIED_COUPONID = 101;

                objcouponref.APPLIED_COUPONNAME = objcoupon.APPLIED_COUPONNAME;
                objcouponref.APPLIED_REFERRALBONUS = true;
                objcouponref.APPLIED_COUPONNAME = COUPONID;
                objcouponref.APPLIED_ADMINCOUPON = false;
                objcouponref.APPLIED_USERCOUPON = true;

                objcouponref.APPLIED_CREATEDDATE = getdate();
                objcouponref.APPLIED_CREATEDBY = 1;
                objcouponref.APPLIED_MODIFIEDBY = 1;
                objcouponref.APPLIED_MODIFIEDDATE = getdate();
                objcouponref.APPLIED_ONETIME = true;
                objcouponref.APPLIED_STATUS = 1;

                objcouponref.APPLIED_USERID = COUPONUSERID;

                objcouponref = db.APPLIEDCOUPONS.Add(objcouponref);
                db.SaveChanges();

                //l00rswalletdeposittransaction
                transaction OBJTRANSref = new transaction();
                OBJTRANSref.TRANS_AMOUNT = decimal.Parse("100.00");
                OBJTRANSref.TRANS_CREATEDBY = 1;
                OBJTRANSref.TRANS_CRETEATEDDATE = getdate();
                OBJTRANSref.TRANS_MODE = 1;
                OBJTRANSref.TRANS_MODENAME = "wallet";
                OBJTRANSref.TRANS_MODIFIEDBY = 1;
                OBJTRANSref.TRANS_MODIFIEDDATE = getdate();
                OBJTRANSref.TRANS_NAME = "CHALO WALLET refered USER ";
                OBJTRANSref.TRANS_STATUS = 1;
                OBJTRANSref.TRANS_USERID = Convert.ToInt32(couponuserid);
                OBJTRANSref.TRANS_CREDIT = true;
                OBJTRANSref.TRANS_DEBIT = false;
                OBJTRANSref = ADDTRANS(OBJTRANSref);
                db.SaveChanges();

                //ADDING WALLET TRANS

               WALLET objwalletref=db.WALLETs.Where(s => s.WALLET_USERID == cid).FirstOrDefault<WALLET>();

                WALLETTRANSACTION OBJWALLETTRANSref = new WALLETTRANSACTION();
                OBJWALLETTRANSref.TRANS_COMMENT = "CHALOWALLET FIRSTTIME USER 100";
                OBJWALLETTRANSref.TRANS_COUPONAPPLIEDID = objcouponref.APPLIED_ID;
                OBJWALLETTRANSref.TRANS_CREATEDBY = 1;
                OBJWALLETTRANSref.TRANS_CREATEDDATE = getdate();
                OBJWALLETTRANSref.TRANS_ID = OBJTRANSref.TRANS_ID;
                OBJWALLETTRANSref.TRANS_MODIFIEDBY = 1;
                OBJWALLETTRANSref.TRANS_MODIFIEDDATE = getdate();
                OBJWALLETTRANSref.TRANS_STATUS = 1;
                OBJWALLETTRANSref.TRANS_TRANSACTIONID = OBJTRANSref.TRANS_ID;
                OBJWALLETTRANSref.TRANS_WALLETID = objwalletref.WALLET_ID;
                OBJWALLETTRANSref.TRANS_WALLETSTATUS = 1;
                OBJWALLETTRANSref.TRANS_WALLETTYPE = 1;
                OBJWALLETTRANSref = db.WALLETTRANSACTIONS.Add(OBJWALLETTRANSref);
                db.SaveChanges();

            WALLET OBJWALLETREFERRED = db.Database.SqlQuery<WALLET>("select * from wallet where wallet_userid=" + cid + "").FirstOrDefault<WALLET>();
            OBJWALLETREFERRED.WALLET_AVAILABLEMONEY = OBJWALLETREFERRED.WALLET_AVAILABLEMONEY+decimal.Parse("100.00");
            db.Entry(OBJWALLETREFERRED).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            }

             return true;
        }
 public IHttpActionResult GETtrips(string DRIVERID)
 {
     var entityContext = new CHALOEntities();
     List<DRIVERTRIPSENTITY> listtrips = entityContext.Database.SqlQuery<DRIVERTRIPSENTITY>("exec [USP_DRIVERSAPP] @OPERATION='PENDINGTRIPS',@driver_id=" + DRIVERID + "").ToList();
     return Ok(listtrips);
 }