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);
        }
        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 });
        }
Esempio n. 4
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;
        }