public string SaveUserOTP(string loginId) { /* var ConfirmUser = _repository.Single(c => c.LoginId == loginId); * * var id = ConfirmUser.EmployeeId.Value;*/ var data = _unitOfWork.DealerInformation.GetDealerUsers(loginId); if (data != null) { int validMin = 10; var otp = new Random().Next(100000, 999999).ToString(); var otpMsg = new OtpMessageDto(); otpMsg.DealerId = data.DealerId; otpMsg.OTP = otp; otpMsg.UserId = data.UserId; otpMsg.GenerateTime = DateTime.Now; // otpMsg.GenerateTime = DateTime.Now; var exOtp = _unitOfWork.UserOtp.Get(s => s.UserId == data.UserId && s.IsUsedToken == null).FirstOrDefault(); var usetOtp = new UserOtp(); if (exOtp != null && exOtp.UserOtpId > 0) { usetOtp = exOtp; usetOtp.ValidToDate = DateTime.Now.AddMinutes(validMin); usetOtp.Password = otp; //if (exOtp.ValidToDate > DateTime.Now) //{ //} } else { usetOtp.UserId = data.UserId; usetOtp.Email = data.EmailAddress; usetOtp.Password = otp; usetOtp.GenerateTime = otpMsg.GenerateTime; usetOtp.ValidToDate = otpMsg.GenerateTime.AddMinutes(validMin); usetOtp.MobileNo = data.MobileNo; otpMsg.ValidMinutes = validMin; usetOtp.IsUsedToken = false; usetOtp = _unitOfWork.UserOtp.Save(usetOtp); } if (usetOtp.UserOtpId > 0) { otpMsg.UserName = data.DealerName; otpMsg.UserOtpId = usetOtp.UserOtpId; if (_userNotificationService.SentOtp(otpMsg)) { usetOtp.SendingStatus = true; usetOtp.SendingTime = DateTime.Now; _unitOfWork.UserOtp.Update(usetOtp); _unitOfWork.Commit(); return("Sucess"); } else { return("Failed"); } } } return(null); }