Пример #1
0
        internal MessageEntityDto BuildOTPMessage(OtpMessageDto delar)
        {
            MessageEntityDto message = null;
            int emailTitleId         = 201;


            EmailContent emailContent = _unitOfWork.EmailContent.GetContentByTitleId(emailTitleId);

            if (emailContent.EmailBody != null)
            {
                message                  = new MessageEntityDto();
                message.SMSText          = string.Format(emailContent.Smsbody, delar.OTP, delar.ValidMinutes);
                message.NotificationText = string.Format(emailContent.NotifcationBody, delar.UserName, delar.OTP, delar.ValidMinutes);
                message.FromHrRecordId   = 1;
                message.ToMessageDetails = base.BuildToMessageDetails(delar.UserId);
                //message.CcMessageDetails = BuildCcMessageDetails();
                message.MessageSubject = string.Format(emailContent.EmailSubject);
                message.MessageDetails = string.Format(emailContent.EmailBody, delar.UserName, delar.OTP, delar.ValidMinutes);
                message.MessagingDate  = DateTime.Now;
                message.ReferenceId    = delar.UserOtpId;
                message.ReferenceType  = 1;
                //  message.MenuId = _messageService.MenuId;
                message.ModuleId                = 1;
                message.RedirectLink            = "";
                message.ReferenceDate           = delar.GenerateTime;
                message.EmailTitleId            = emailContent.EmailTitleId ?? 0;
                message.EmailNotificationTypeId = 2;
                message.ArchiveTime             = (DateTime?)null;
            }
            return(message);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public bool SentOtp(OtpMessageDto obj)
        {
            var messgeg = BuildOTPMessage(obj);

            return(base.SentMessage(messgeg));
        }