Пример #1
0
        public DL_AccountRegistrationReturn AccountRegistration(DL_AccountRegistration accountReg)
        {
            this.SpName      = DL_StoreProcedure.SP_DHS_API_BankRegistration; //Sp Name
            accountRegReturn = new DL_AccountRegistrationReturn();
            _IsSuccess       = true;
            try
            {
                int            otp   = (new Random(1000)).Next(9999);
                SqlParameter[] param = new SqlParameter[8];
                param[0] = new SqlParameter("@Name", accountReg.Name);
                param[1] = new SqlParameter("@Key", accountReg.Key);//change in future
                param[2] = new SqlParameter("@Mobile", accountReg.Mobile);
                param[3] = new SqlParameter("@UserId", accountReg.UserId);
                param[4] = new SqlParameter("@Account", accountReg.Account);
                param[5] = new SqlParameter("@IFSC", accountReg.IFSC);
                param[6] = new SqlParameter("@OTP", otp);
                param[7] = new SqlParameter("@Amount", accountReg.Amount);

                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    var row = ds.Tables[0].Rows[0];
                    accountRegReturn = new DL_AccountRegistrationReturn {
                        status = row["status"].ToString()
                    };
                    //  string message = "Dear " + accountReg.Name + " , Account No.  " + accountReg.Account + " has been successfully registered. CREBIT Customer Experience Team.";

                    //Non Blocking thread
                    //Task t = new Task(() => BL_SMS.SendSMS(accountReg.Mobile, message));
                    //t.Start();
                }
            }
            catch (Exception ex)
            {
                Exception err = ex;
                _IsSuccess = false;
            }

            return(accountRegReturn);
        }
        public HttpResponseMessage AccountRegistration(HttpRequestMessage req, DL_AccountRegistration accountReg)
        {
            User user = new User()
            {
                Password = accountReg.Key, UserId = accountReg.UserId
            };

            Validation.UserCheck(user);
            if (Validation._IsSuccess)
            {
                try
                {
                    if (accountReg != null && !string.IsNullOrEmpty(accountReg.Name) && !string.IsNullOrEmpty(accountReg.UserId) &&
                        !string.IsNullOrEmpty(accountReg.Mobile) && !string.IsNullOrEmpty(accountReg.Key))
                    {
                        DL_AccountRegistrationReturn accountRegReturn = dash.AccountRegistration(accountReg);
                        if (dash._IsSuccess)
                        {
                            return(req.CreateResponse <DL_AccountRegistrationReturn>(HttpStatusCode.OK, accountRegReturn));
                        }
                        else
                        {
                            return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, "ServerError"));
                        }
                    }
                    Logger.WriteLog(LogLevelL4N.FATAL, "Bad Request");
                    return(req.CreateResponse(HttpStatusCode.BadRequest, "Bad Request"));
                }
                catch (Exception ex)
                {
                    Logger.WriteLog(LogLevelL4N.ERROR, "Inside the Account Registration api | Error : " + ex.Message);
                    return(req.CreateResponse(HttpStatusCode.BadRequest, "Bad Request"));
                }
            }
            Logger.WriteLog(LogLevelL4N.FATAL, "Unauthorized Request");
            return(req.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized"));
        }