public void OtpSent(UserLoginInformation ulinfo, int loginUserId)
        {
            var user = _context.UserRegistrationOTPs.SingleOrDefault(u => u.USERID.Equals(ulinfo.USERID));

            if (user == null)
            {
                var number = GenerateOTP(11);
                using (var transactionscope = new TransactionScope())
                {
                    bool value;
                    try
                    {
                        using (var db = new kryptoEntities1()) // Context object
                        {
                            try
                            {
                                var usRegOtp = new UserRegistrationOTP
                                {
                                    USERID       = ulinfo.USERID,
                                    OTP          = number,
                                    Status       = 2,
                                    Notes        = "",
                                    CreatedById  = loginUserId.ToString(),
                                    ModifiedById = loginUserId.ToString(),
                                    CreatedDate  = DateTime.Now,
                                    ModifiedDate = DateTime.Now
                                };
                                db.UserRegistrationOTPs.Add(usRegOtp);
                                db.SaveChanges();
                                value = true;
                                transactionscope.Complete();
                            }
                            catch (Exception)
                            {
                                value = false;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        value = false;
                    }
                    if (value)
                    {
                        SendOTPMail(number, ulinfo.EmailId, ulinfo.FirstName + " " + ulinfo.LastName);
                    }
                }
            }
        }
        public void OtpSent(UserLoginInformation ulinfo, int LoginUserId)
        {
            // _context.Database.Connection.Open();
            UserRegistrationOTP user = _context.UserRegistrationOTPs.SingleOrDefault(I => I.USERID.Equals(ulinfo.USERID));

            if (user == null)
            {
                bool   value  = false;
                string Number = GenerateOTP(11);
                using (TransactionScope transactionscope = new TransactionScope())
                {
                    try
                    {
                        UserRegistrationOTP UsRegOtp = new UserRegistrationOTP();
                        UsRegOtp.USERID       = ulinfo.USERID;
                        UsRegOtp.OTP          = Number;
                        UsRegOtp.Status       = 1;
                        UsRegOtp.Notes        = "";
                        UsRegOtp.CreatedById  = LoginUserId.ToString();
                        UsRegOtp.ModifiedById = LoginUserId.ToString();
                        UsRegOtp.CreatedDate  = DateTime.Now;
                        UsRegOtp.ModifiedDate = DateTime.Now;
                        _context.UserRegistrationOTPs.Add(UsRegOtp);
                        _context.SaveChanges();
                        value = true;
                        transactionscope.Complete();
                    }
                    catch (Exception)
                    {
                        value = false;
                    }
                }
                if (value == true)
                {
                    SendEmail("OTP", Number, ulinfo.EmailId, ulinfo.FirstName + ulinfo.LastName);
                }
            }
        }