//Check ForgotPassword
 public DL_ForgotPasswordReturn ForgotPassword(DL_ForgotPassword forgotPass)
 {
     forgotPassReturn = new DL_ForgotPasswordReturn();
     this.SpName      = DL_StoreProcedure.SP_DHS_API_ForgotPassword; //Sp Name
     _IsSuccess       = true;
     try
     {
         SqlParameter[] param = new SqlParameter[1];
         param[0] = new SqlParameter("@Mobile", forgotPass.Mobile);
         ds       = db.GetDataSet(this.SpName, param);
         if (ds != null && ds.Tables.Count > 0)
         {
             forgotPassReturn.Status = ds.Tables[0].Rows[0]["Status"].ToString();
             string password = ds.Tables[0].Rows[0]["Password"].ToString();
             if (forgotPassReturn.Status == "2")//success
             {
                 //Dear User, Your password is ##Field## . Crebit Customer Experience Team.
                 string message = "Dear User, Your password is " + password + " . Crebit Customer Experience Team.";
                 //string message = "Dear User, Your password is " + password + ". Crebit Customer Experience Team.";
                 BL_SMS.SendSMS(forgotPass.Mobile, message);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLog(LogLevelL4N.ERROR, "ForgotPassword | Exception : " + ex.Message);
         _IsSuccess = false;
     }
     return(forgotPassReturn);
 }
 //Check ChangePassword
 public DL_ChangePasswordReturn ChangePassword(DL_ChangePassword changePass)
 {
     ChangePassReturn = new DL_ChangePasswordReturn();
     this.SpName      = DL_StoreProcedure.SP_DHS_API_ChangePassword; //Sp Name
     _IsSuccess       = true;
     try
     {
         SqlParameter[] param = new SqlParameter[4];
         param[0] = new SqlParameter("@UserId", changePass.UserId);
         param[1] = new SqlParameter("@OldPassword", changePass.OPass);
         param[2] = new SqlParameter("@NewPassword", changePass.NPass);
         param[3] = new SqlParameter("@Key", changePass.Key);
         ds       = db.GetDataSet(this.SpName, param);
         if (ds != null && ds.Tables.Count > 0)
         {
             ChangePassReturn.Status = ds.Tables[0].Rows[0]["Status"].ToString();
             string mobile = ds.Tables[0].Rows[0]["Mobile"].ToString();
             if (ChangePassReturn.Status == "1")
             {
                 string message = "Dear User, your Password has been changed.Your password is" + changePass.NPass + ". Crebit Customer Experience Team.";
                 //Non Blocking code
                 Task t = new Task(() => BL_SMS.SendSMS(mobile, message));
                 t.Start();
             }
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLog(LogLevelL4N.ERROR, "ChangePassword | Exception : " + ex.Message);
         _IsSuccess = false;
     }
     return(ChangePassReturn);
 }
        //Mobile Regis
        public DL_MobileRegistrationReturn MobileRegistration(DL_MobileRegistration mobileReg)
        {
            this.SpName     = DL_StoreProcedure.SP_InsertRegisterMobile; //Sp Name
            mobileRegReturn = new DL_MobileRegistrationReturn();
            _IsSuccess      = true;
            try
            {
                SqlParameter[] param = new SqlParameter[4];
                param[0] = new SqlParameter("@Name", mobileReg.Name);
                param[1] = new SqlParameter("@UserType", mobileReg.Key);//change in future
                param[2] = new SqlParameter("@MobileNo", mobileReg.Mobile);
                param[3] = new SqlParameter("@UserId", mobileReg.UserId);

                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    //ds.Tables
                    var Json = JsonConvert.SerializeObject(ds.Tables[0]).TrimEnd(']').TrimStart('[');
                    mobileRegReturn = JsonConvert.DeserializeObject <DL_MobileRegistrationReturn>(Json);
                    string message = "Dear " + mobileReg.Name + " , Mobile No.  " + mobileReg.Mobile + " has been successfully registered. CREBIT Customer Experience Team.";
                    BL_SMS.SendSMS(mobileReg.Mobile, message);
                }
            }
            catch (Exception ex)
            {
                Exception err = ex;
                _IsSuccess = false;
            }

            return(mobileRegReturn);
        }
示例#4
0
        //Fund Transfer
        public List <DL_TransferFundReturn> TransferFund(DL_TransferFund fund)
        {
            this.SpName = DL_StoreProcedure.SP_DHS_API_TransferFund; //Sp Name
            fundReturn  = new List <DL_TransferFundReturn>();
            _IsSuccess  = true;
            try
            {
                SqlParameter[] param = new SqlParameter[5];
                param[0] = new SqlParameter("@UserId", fund.UserId);
                param[1] = new SqlParameter("@MobileTo", fund.MobileTo);
                param[2] = new SqlParameter("@Amount", fund.Amount);
                param[3] = new SqlParameter("@Date", indianTime);
                param[4] = new SqlParameter("@Source", 1);

                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    //ds.Tables
                    var Json = JsonConvert.SerializeObject(ds.Tables[0]);
                    fundReturn = JsonConvert.DeserializeObject <List <DL_TransferFundReturn> >(Json);
                    string reMobile = ds.Tables[0].Rows[0]["Mobile"].ToString();
                    string status   = ds.Tables[0].Rows[0]["Status"].ToString();
                    if (status == "2" || status == "1")
                    {
                        //Added Task for SMS message
                        //Modified : SMS template
                        //By : Ranjeet | 12-Dec-14
                        Task t = new Task(() =>
                        {
                            //Rs. ##Field## has been successfully transfer to Mobile No. ##Field## User. Crebit Customer Experience Team.
                            string message = "Rs. " + fund.Amount + " has been successfully transfer to Mobile No. " + fund.MobileTo + " User. Crebit Customer Experience Team.";
                            //string message = "Rs." + fund.Amount + "has been successfully transfer to Mobile No. " + fund.MobileTo + " User. Crebit Customer Experience Team.";
                            BL_SMS.SendSMS(reMobile, message);
                            //Rs. ##Field# #has been successfully received from Mobile No. ##Field## User. Crebit Customer Experience Team.
                            message = "Rs. " + fund.Amount + " has been successfully received from Mobile No. " + reMobile + " User. Crebit Customer Experience Team.";
                            BL_SMS.SendSMS(fund.MobileTo, message);
                        });
                        t.Start();//Run task
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(LogLevelL4N.ERROR, "Error @ TransferFund : " + ex.Message);
                _IsSuccess = false;
            }

            return(fundReturn);
        }
示例#5
0
        //Check login
        public List <DL_SignUpReturn> SignUp(DL_SignUp signUp)
        {
            this.SpName = DL_StoreProcedure.SP_DHS_API_SignUp; //Sp Name
            _IsSuccess  = true;
            try
            {
                SqlParameter[] param = new SqlParameter[5];
                param[0] = new SqlParameter("@Name", signUp.Name);
                param[1] = new SqlParameter("@Password", signUp.Pass);
                param[2] = new SqlParameter("@Mobile", signUp.Mobile);
                param[3] = new SqlParameter("@UserType", signUp.UserType);
                param[4] = new SqlParameter("@Date", indianTime);

                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    signUpReturn = SerializeData.SerializeMultiValue <DL_SignUpReturn>(ds.Tables[0]);
                    //send message
                    foreach (var t in signUpReturn)
                    {
                        if (t.Status == "1")//suceess
                        {
                            Task task = new Task(() =>
                            {
                                string message = "Dear " + signUp.Name + " , your UserName is " + signUp.Mobile + " and password is " + signUp.Pass + " . Crebit Customer Experience Team.";
                                BL_SMS.SendSMS(signUp.Mobile, message);
                            });

                            task.Start();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _IsSuccess = false;
                Logger.WriteLog(LogLevelL4N.ERROR, "SignUp | Exception : " + ex.Message);
            }
            return(signUpReturn);
        }
        public DL_ServiceReturn Service(DL_Service service)
        {
            try
            {
                this._IsSuccess    = true;
                this.serviceReturn = new DL_ServiceReturn();
                ProcessReqReturn rechargeStatus = new ProcessReqReturn();

                #region Check Account available balance and servie status.

                this.SpName = DL_StoreProcedure.SP_DHS_API_AvailableBalanceNServieStatus; //Sp Name || Get the Available balance and Service status.
                SqlParameter[] p = new SqlParameter[2];
                p[0] = new SqlParameter("@UserId", service.UserId);
                p[1] = new SqlParameter("@OpId", service.OperatorId);
                ds   = db.GetDataSet(this.SpName, p);
                UserInfo userInfo = null;

                if (ds != null && ds.Tables.Count > 0)
                {
                    DataRow drc = ds.Tables[0].Rows[0];

                    userInfo = new UserInfo()
                    {
                        AvailBal      = Convert.ToDouble(drc["AvailableBalance"] != null ? drc["AvailableBalance"] : 0),
                        Margin        = Convert.ToDouble(drc["Margin"]),
                        ServiceStatus = Convert.ToBoolean(drc["ServiceStatus"]),
                        UType         = Convert.ToInt32(drc["UType"]),
                        IsFixedCharge = Convert.ToBoolean(drc["IsFixedCharge"])
                    };
                }

                #endregion

                #region Call Cyber Plate APIs

                if (userInfo.AvailBal >= service.Amount && userInfo.ServiceStatus)
                {
                    //if (!string.IsNullOrEmpty(service.InsuranceDob) && (Convert.ToInt32(service.OperatorId) == 243) || Convert.ToInt32(service.OperatorId) == 242)//Insurance
                    //account = service.InsuranceDob;
                    rechargeStatus = new RechargeProcess().ProcessRequest(service.OperatorId, service.Number, service.Amount, service.Account);

                    //double profit = 0;
                    string transactionId = string.IsNullOrEmpty(rechargeStatus.TransactionId) ? "-1" : rechargeStatus.TransactionId;
                    string status        = rechargeStatus.StatusCode == 1 ? "1" : "0"; //check once
                    int    apiId         = (int)APIName.Cyber_Plate;                   //"CyberPate";
                    string billRecieptId = string.Empty;

                    //Profit ||
                    //check || Postpaid,electricity, gas bill, insurense and broadband
                    if (rechargeStatus.StatusCode == 1)
                    {
                        //if (userInfo.IsFixedCharge)
                        //{
                        //    profit = 0; //No Profit
                        //    //service.Amount = service.Amount+ userInfo.Margin;//Fixed charges from Crebit
                        //}
                        //else
                        //{
                        //    profit = ((service.Amount * userInfo.Margin) / 100); //Percentage margin
                        //}
                    }
                    else //Fail
                    {
                        //profit = 0;
                        service.Amount = 0;
                    }

                    #region SQLParameters

                    this.SpName = DL_StoreProcedure.SP_DHS_API_Service; //Sp Name
                    SqlParameter[] param = new SqlParameter[10];
                    param[0] = new SqlParameter("@UserId", service.UserId);
                    param[1] = new SqlParameter("@Number", service.Number);
                    param[2] = new SqlParameter("@Amount", service.Amount);
                    //param[3] = new SqlParameter("@Profit", profit);
                    param[3] = new SqlParameter("@ApiTransactionId", transactionId); //transId from CyberPlate
                    param[4] = new SqlParameter("@OperaterId", service.OperatorId);
                    param[5] = new SqlParameter("@Status", status);                  //'1-pass' || '0-fail'
                    param[6] = new SqlParameter("@Source", service.Source);          //'website/androidapp'
                    param[7] = new SqlParameter("@ApiId", apiId);                    //CyberPlate
                    param[8] = new SqlParameter("@Date", indianTime);
                    param[9] = new SqlParameter("@Session", rechargeStatus.SessionId);

                    #endregion

                    ds = db.GetDataSet(this.SpName, param);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        serviceReturn.TransId          = dr["TransId"].ToString();
                        serviceReturn.AvailableBalance = dr["AvBalance"].ToString();
                        string reMobile = dr["Mobile"].ToString();
                        //AvBalance
                        serviceReturn.StatusCode = rechargeStatus.StatusCode; //success
                        #region commented || SMS || Not required || 05-Aug-14
                        if (serviceReturn.StatusCode == 1)
                        {
                            //send message to retailer
                            //Dear USER ##Field##. Recharge successful on ##Field## for Rs. ##Field##.Your Available Balance is ##Field##.CREBIT Customer Experience Team.
                            //string message = "Dear USER " + service.UserId + ". Recharge successful on " + service.Number + " for Rs.  " + service.Amount + ".Your Available Balance is " + serviceReturn.AvailableBalance + ".CREBIT Customer Experience Team.";
                            //string message = "Dear User" + service.UserId + ". Recharge successful on " + service.Number + " for Rs. " + service.Amount + ".Your Available Balance is " + serviceReturn.AvailableBalance + " .Crebit Customer Experience Team.";

                            //send meesage to customer > amount => 250
                            string message = "Dear User, Recharge successful on " + service.Number + " for Rs." + service.Amount + " .CREBIT Customer Experience Team.";

                            if (service.Amount >= 250)
                            {
                                Task t = new Task(() => BL_SMS.SendSMS(service.Number, message));
                                t.Start();
                            }
                            //send message to customer
                            //if (service.TransactionType == "1" || service.TransactionType == "2")
                            {
                                //  message = "Dear Customer, Your account has been successfully recharged for Rs. " + service.Amount + " .Crebit Customer Experience Team.";
                                //BL_SMS.SendSMS(service.Number, message);
                            }
                        }
                        #endregion
                    }
                    serviceReturn.Message = rechargeStatus.Message;
                }
                #endregion

                #region If Either not enough balance or Servie if Off
                else
                {
                    //serviceReturn.IsSuccess = false;
                    serviceReturn.TransId = null;

                    if (userInfo.AvailBal < service.Amount)
                    {
                        //serviceReturn.Message = "Not enough Balance in account";
                        serviceReturn.StatusCode = 2;
                    }
                    else
                    {
                        //serviceReturn.Message = "Serice is Off";
                        serviceReturn.StatusCode = 3;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Logger.WriteLog(LogLevelL4N.ERROR, "@Service | Exception : " + ex.Message);
                serviceReturn.StatusCode = 0; //error
                serviceReturn.TransId    = null;
                _IsSuccess = false;
            }

            return(serviceReturn);
        }