Пример #1
0
        //--------------------------------------------------------------------------------------------------------


        /// <summary>
        /// This generates unique random numbers for
        /// </summary>
        /// <param name="qty"></param>
        /// <param name="numberLength"></param>
        /// <returns></returns>
        private List <string> GenerateRandomNumbers(long qty, int numberLength)
        {
            var  rndmg        = new RandomNoGenerator(numberLength);
            long maxNumber    = rndmg.MaxNumberForLength(numberLength);
            var  rgStringList = rndmg.GetStringListOfRandomNumbersWithExclusionList(
                qty,
                0,
                maxNumber,
                GetCurrentListOfNumberStrings()); //this is the current list of scratch card numbers in the system.

            return(rgStringList);
        }
Пример #2
0
        public void PrepareEncashmentForUser(string userId, string userName, CashEncashmentTrx cet)
        {
            userId.IsNullOrWhiteSpaceThrowArgumentException("You must be logged in");
            cet.PaymentMethodId.IsNullOrWhiteSpaceThrowException("No method selected");


            decimal currBalanceForUser = BalanceFor_User(userId, CashTypeENUM.Refundable);

            if (currBalanceForUser != cet.CurrentBalance_Refundable)
            {
                throw new Exception("Something is wrong. Previous balance does not match current balance.");
            }

            if (currBalanceForUser >= cet.Amount)
            {
                cet.IsApproved.MarkTrue(UserName, UserId);
                RandomNoGenerator randomGen = new RandomNoGenerator(3);
                cet.SecretNumber = randomGen.GetRandomNumber(1);

                PaymentMethod paymentMethod = PaymentMethodBiz.Find(cet.PaymentMethodId);
                paymentMethod.IsNullThrowException();

                cet.SystemMessageToApplicant = paymentMethod.DetailInfoToDisplayOnWebsite;

                Person userPerson = UserBiz.GetPersonFor(userId);
                userPerson.IsNullThrowException("Person not found");
                cet.PersonRequestingPaymentId = userPerson.Id;

                if (userPerson.CashEncashmentTrxs.IsNull())
                {
                    userPerson.CashEncashmentTrxs = new List <CashEncashmentTrx>();
                }
                userPerson.CashEncashmentTrxs.Add(cet);
                CashEncashmentTrxBiz.CreateAndSave(cet);

                ErrorsGlobal.AddMessage("Encashment certificate created and approved.");
            }
            else
            {
                throw new Exception("Something went wrong. You do not have the balance");
            }
        }
Пример #3
0
        //public override string SelectListCacheKey
        //{
        //    get { return "EmailAddressesSelectListData"; }

        //}


        /// <summary>
        /// This sends the user an email verification code to their email address to verify their email
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="emailAddressId"></param>
        public void SendEmailConfirmation(string emailAddressId, GlobalObject globalObject)
        {
            UserId.IsNullThrowException("You are not logged in");
            emailAddressId.IsNullOrWhiteSpaceThrowArgumentException("emailAddressId");

            //get the email address.
            EmailAddress emailAddress = Find(emailAddressId);

            emailAddress.IsNullThrowException("Email Not found");

            RandomNoGenerator randomGen          = new RandomNoGenerator(5);
            string            verificationNumber = randomGen.GetRandomNumber(1000);

            verificationNumber.IsNullOrWhiteSpaceThrowArgumentException("Random number not generated");

            emailAddress.VerificationNumber = verificationNumber.ToString();
            emailAddress.VerificationDateComplex.SetToTodaysDate(UserName, UserId);
            //time allowed for verification is 60 min.



            string body       = string.Format("Your verification Id is: {0}", verificationNumber);
            string subject    = string.Format("Verification for email: {0}", emailAddress.Name);
            string smtpServer = ConfigManagerHelper.SmtpServer;

            string portStr = ConfigManagerHelper.SmtpPort;

            portStr.IsNullOrWhiteSpaceThrowArgumentException("No port has been listed.");
            int  portInt;
            bool success = int.TryParse(portStr, out portInt);

            if (!success)
            {
                throw new Exception("The port number is not a number.");
            }


            string userName = ConfigManagerHelper.SmtpUser;
            string from     = ConfigManagerHelper.SmtpFromEmailAddress;
            string password = ConfigManagerHelper.SmtpPassword;

            List <string> sendToList = new List <string>();

            sendToList.Add(emailAddress.Name);
            Emails emailClient = new Emails(smtpServer, portInt, userName, password, true);

            try
            {
                emailClient.SendEmailMsg(from, subject, body, sendToList, null);

                emailAddress.VerificationStatusEnum = VerificaionStatusENUM.Mailed;

                ControllerCreateEditParameter param = new ControllerCreateEditParameter();
                param.Entity       = emailAddress as ICommonWithId;
                param.GlobalObject = globalObject;

                PersonBiz.UpdateAndSave(param);

                //UpdateAndSave(emailAddress);
                ErrorsGlobal.AddMessage(string.Format("Verification Email Sent to: '{0}'", emailAddress.Name));
            }
            catch (Exception e)
            {
                ErrorsGlobal.Add(string.Format("Unable to send Email to: '{0}'", emailAddress.Name), MethodBase.GetCurrentMethod(), e);
            }
        }