Example #1
0
        public async Task <long> GenerateOTPAsync(int customerId)
        {
            long        otp         = SharedUtilities.GenerateOTPHaving(ApplicationConstants.OTP_LENGTH);
            DateTime    validUpTo   = DateTime.UtcNow.AddMinutes(ApplicationConstants.OTP_LIFE_IN_MINUTES);
            CustomerOTP customerOTP = new CustomerOTP(customerId, otp, validUpTo);

            if (!await CustomerRepository.GenerateSignUpOTPAsync(customerOTP))
            {
                throw new SignUpOTPGenerationFailedException(otp, customerId);
            }
            return(otp);
        }
Example #2
0
        public async Task <CustomerOTP> FindOTP(int customerId, double OTP)
        {
            var spName   = "spFindCustomerSignUpOTPForVerification";
            var spParams = new DynamicParameters();

            spParams.Add("@CustomerId", customerId);
            spParams.Add("@OTP", OTP);

            using (IDbConnection connection = ConnectionFactory.SQLConnection)
            {
                CustomerOTP customerOTP = await connection.QueryFirstAsync <CustomerOTP>(spName, spParams, commandType : CommandType.StoredProcedure);

                return(customerOTP);
            }
        }
Example #3
0
        public async Task <bool> GenerateSignUpOTPAsync(CustomerOTP customerOTP)
        {
            var spName   = "spGenerateSignUpOTP";
            var spParams = new DynamicParameters();

            spParams.Add("@CustomerId", customerOTP.CustomerId);
            spParams.Add("@OTP", customerOTP.OTP);
            spParams.Add("@ValidUpTo", customerOTP.ValidUpTo, dbType: DbType.DateTime);

            using (IDbConnection connection = ConnectionFactory.SQLConnection)
            {
                int rowsAffected = await connection.ExecuteAsync(spName, spParams, commandType : CommandType.StoredProcedure);

                return(rowsAffected > 0);
            }
        }
        public static void RegisterOld(Models.Input <WalletProfile> obj)
        {
            PayitMerchantsnWalletsEntities db = new PayitMerchantsnWalletsEntities();
            var isWalletExist = (from a in db.Customers
                                 join b in db.CustomerDevices on a.ID equals b.CustomerID
                                 where a.MobileNo == obj.input.mobileno && b.DeviceUDID == obj.param.deviceuniqueid
                                 select a).FirstOrDefault();

            if (isWalletExist == null)
            {
                Customer cus = new Customer();

                cus.CountryCode     = string.IsNullOrEmpty(obj.input.countrycode) ? "" : obj.input.countrycode;
                cus.CustomerCode    = string.IsNullOrEmpty(obj.input.userid) ? "" : obj.input.userid;
                cus.Password        = string.IsNullOrEmpty(obj.input.password) ? "" : obj.input.password;
                cus.MobileNo        = string.IsNullOrEmpty(obj.input.mobileno) ? "" : obj.input.mobileno;
                cus.MobileActivated = false;
                cus.OTP             = 0;
                cus.Email           = string.IsNullOrEmpty(obj.input.email) ? "" : obj.input.email;
                cus.EmailActivated  = false;
                //cus.AppIdentifier="";
                cus.TranDate = DateTime.Now;
                cus.Status   = false;
                db.Customers.Add(cus);
                db.SaveChanges();


                var CID = cus.ID;

                CustomerDevice CusD = new CustomerDevice();

                CusD.CustomerID = CID;
                CusD.DeviceUDID = obj.param.deviceuniqueid;
                CusD.Status     = false;
                CusD.CreatedDae = DateTime.Now;
                db.CustomerDevices.Add(CusD);
                db.SaveChanges();

                var DeviceID = CusD.ID;

                CustomerWallet CusW = new CustomerWallet();
                CusW.CustomerID  = CID;
                CusW.Balance     = 0;
                CusW.CreatedDate = DateTime.Now;
                CusW.Status      = true;

                db.CustomerWallets.Add(CusW);
                db.SaveChanges();

                CustomerOTP CusO = new CustomerOTP();
                CusO.CusomerID       = CID;
                CusO.DeviceID        = DeviceID;
                CusO.WalletServiceID = 1;
                CusO.OTP             = "";
                CusO.CreatedDate     = DateTime.Now;
                CusO.Status          = true;
                CusO.isUsed          = false;
                db.CustomerOTPs.Add(CusO);
                db.SaveChanges();
            }
        }