public ActionResult GetOTPNo(string mobileNo) { try { String no = null; Random random = new Random(); for (int i = 0; i < 1; i++) { int n = random.Next(0, 999); no += n.ToString("D4") + ""; } // ApplicationUserViewModelDtos objApplicationUserViewModelDtos = new ApplicationUserViewModelDtos(); var obj = _unitofWork.applicationUser.GetAll().Where(x => x.PhoneNumber == mobileNo.Trim()).FirstOrDefault(); if (obj != null) { //var Dtosobj = new ApplicationUserViewModelDtos(); //Dtosobj = _mapper.Map<ApplicationUserViewModelDtos>(obj); string myJson = "{\"message\": " + "\"This Mobile Number Allready Exist\"" + "}"; return(StatusCode(409, myJson)); // return Ok(Dtosobj); } else { string Msg = "OTP :" + no + ". Please Use this OTP.This is usable once and expire in 10 minutes"; SendSMS s = new SendSMS(); bool flg = s.smsSent(mobileNo, Msg); ApplicationUserViewModelDtos objApplicationUserViewModelDtos = new ApplicationUserViewModelDtos(); objApplicationUserViewModelDtos.OTPNo = no; objApplicationUserViewModelDtos.PhoneNumber = mobileNo; return(Ok(objApplicationUserViewModelDtos)); // return Ok(objApplicationUserViewModelDtos); } } catch (Exception obj) { return(BadRequest()); } }
public async Task <ActionResult> LoginWithMobileNo(string mobileNo) { if (!string.IsNullOrEmpty(mobileNo)) { var obj = _unitofWork.applicationUser.GetAll().Where(x => x.PhoneNumber == mobileNo).FirstOrDefault(); if (obj == null) { ModelState.AddModelError("", "Mobile No Not Found"); return(StatusCode(404, ModelState)); } else { String no = null; Random random = new Random(); for (int i = 0; i < 1; i++) { int n = random.Next(0, 999); no += n.ToString("D4") + ""; } string Msg = "OTP :" + no + ". Please Use this OTP.This is usable once and expire in 10 minutes"; SendSMS s = new SendSMS(); bool flg = s.smsSent(mobileNo, Msg); var Dtosobj = new LoginWhiteMobilenoandPasswordDtos(); Dtosobj = _mapper.Map <LoginWhiteMobilenoandPasswordDtos>(obj); Dtosobj.OTP = no; return(Ok(Dtosobj)); } } else { ModelState.AddModelError("", "Please Enter Mobile No"); return(StatusCode(404, ModelState)); } }
public async Task <IActionResult> getOTPNo(string mobileno) { try { String no = null; Random random = new Random(); for (int i = 0; i < 1; i++) { int n = random.Next(0, 999); no += n.ToString("D4") + ""; } //string Msg = "OTP :" + no + ". Please Use this OTP.This is usable once and expire in 10 minutes"; string Msg = "OTP : " + no + " Please Use this OTP to Register with TOFOZ. This is usable once and expire in 10 minutes"; SendSMS objsendSMS = new SendSMS(); bool res = objsendSMS.smsSent(mobileno, Msg); //#region "sms" //try //{ // string Msg = "OTP :" + no + ". Please Use this OTP.This is usable once and expire in 10 minutes"; // string OPTINS = "STRLIT"; // // string Password = "******"; // string Password = "******"; // string type = "3"; // // string strUrl = "https://www.bulksmsgateway.in/sendmessage.php?user=ezacus&password="******"ezacus@2020" + "&message=" + Msg.ToString() + "&sender=" + OPTINS + "&mobile=" + mobileno + "&type=" + 3; // //string strUrl = "https://www.bulksmsgateway.in/sendmessage.php?user=ezacus&password="******"ezacus@2020" + "&message=" + Msg.ToString() + "&sender=" + OPTINS + "&mobile=" + mobileno + "&type=" + 3; // string strUrl = "http://bulksms.co/sendmessage.php?user=Aveebroiler&password="******"&message=" + Msg + "&sender=" + OPTINS + "&mobile=" + mobileno + "&type=" + 3; // ServicePointManager.Expect100Continue = true; // ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // System.Net.WebRequest request = System.Net.WebRequest.Create(strUrl); // HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Stream s = (Stream)response.GetResponseStream(); // StreamReader readStream = new StreamReader(s); // string dataString = readStream.ReadToEnd(); // response.Close(); // s.Close(); // readStream.Close(); // // Response.Write("Sent"); //} //catch //{ } //#endregion CustomerRegistrationOTPViewModel objCustomerRegistrationOTPViewModel = new CustomerRegistrationOTPViewModel(); CustomerRegistration obj = CustomerRegistrationservices.GetAll().Where(x => x.mobileno1 == mobileno && x.isdeleted == false).FirstOrDefault(); // var categories = await _context.CustomerRegistration.ToListAsync(); if (obj == null) { //string myJson = "{'otpno': "+ no + "}"; //return Ok(myJson); // objCustomerRegistrationOTPViewModel.id = obj.id; //objCustomerRegistrationOTPViewModel.name = ""; //objCustomerRegistrationOTPViewModel.profilephoto = ""; //objCustomerRegistrationOTPViewModel.address = ""; //objCustomerRegistrationOTPViewModel.mobileno1 = ""; //objCustomerRegistrationOTPViewModel.mobileno2 = ""; //objCustomerRegistrationOTPViewModel.emailid1 = ""; //objCustomerRegistrationOTPViewModel.latitude = ""; //objCustomerRegistrationOTPViewModel.longitude = ""; //objCustomerRegistrationOTPViewModel.password = ""; //objCustomerRegistrationOTPViewModel.mobileno2 = ""; //objCustomerRegistrationOTPViewModel.gender = ""; // objCustomerRegistrationOTPViewModel.DOB = obj.DOB; // objCustomerRegistrationOTPViewModel.createddate = obj.createddate; // objCustomerRegistrationOTPViewModel.isdeleted = obj.isdeleted; // objCustomerRegistrationOTPViewModel.isactive = obj.isactive; objCustomerRegistrationOTPViewModel.otpno = no; return(Ok(objCustomerRegistrationOTPViewModel)); } else { objCustomerRegistrationOTPViewModel.id = obj.id; objCustomerRegistrationOTPViewModel.name = obj.name; objCustomerRegistrationOTPViewModel.profilephoto = obj.profilephoto; objCustomerRegistrationOTPViewModel.address = obj.address; objCustomerRegistrationOTPViewModel.mobileno1 = obj.mobileno1; objCustomerRegistrationOTPViewModel.mobileno2 = obj.mobileno2; objCustomerRegistrationOTPViewModel.emailid1 = obj.emailid1; objCustomerRegistrationOTPViewModel.latitude = obj.latitude; objCustomerRegistrationOTPViewModel.longitude = obj.longitude; objCustomerRegistrationOTPViewModel.password = obj.password; objCustomerRegistrationOTPViewModel.mobileno2 = obj.mobileno2; objCustomerRegistrationOTPViewModel.gender = obj.gender; objCustomerRegistrationOTPViewModel.DOB = obj.DOB; objCustomerRegistrationOTPViewModel.createddate = obj.createddate; objCustomerRegistrationOTPViewModel.isdeleted = obj.isdeleted; objCustomerRegistrationOTPViewModel.isactive = obj.isactive; objCustomerRegistrationOTPViewModel.otpno = no; return(Ok(objCustomerRegistrationOTPViewModel)); } } catch (Exception obj) { return(BadRequest()); } }