public object SendOTP(LoginViewModel loginViewModel) { LoginViewModel.ResendCounter++; LoginViewModel.OtpCrtDate = System.DateTime.Now; ViewBag.Email = loginViewModel.Email; LoginViewModel.varEmail = loginViewModel.Email;// because loginviewmodel.email becomes null in registerUser event, so storing it in static thing. LoginViewModel.varOTP = homeBusiness.GenerateOTP().ToString(); if (LoginViewModel.ResendCounter > 3) { ViewBag.ErrorRegister = "OTP resend Limit reached!"; } else { if (commonBusiness.SendEmail("UserRegistration", ViewBag.Email, true, LoginViewModel.varOTP)) { ViewBag.ErrorRegister = "OTP has been sent to Email ID."; } else { ViewBag.ErrorRegister = "There is some problem sending Email. Kindly check if Email provided is correct."; } } ModelState.Clear(); return(View("PreRegister", loginViewModel)); }