Пример #1
0
        //public AddressVerificationRequest GetAddressVerificationRequestConfirmation(AddressVerificationRequest avr)
        //{
        //    var avr2 = GetAddressVerificationRequest(avr.AddressId);
        //    avr2.MailServiceEnum = avr.MailServiceEnum;
        //    avr2.IsSure1 = avr.IsSure1;
        //    avr2.DateIsSure1 = DateTime.UtcNow;
        //    avr2.PaymentAmount = getVerificaionCost(avr2);

        //    return avr2;
        //}

        //double getVerificaionCost(AddressVerificationRequest avr)
        //{
        //    string error = "";
        //    double verificationCost = 0;

        //    switch (avr.MailServiceEnum)
        //    {
        //        case MailServiceENUM.Post:
        //            switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
        //            {
        //                case true:
        //                    //is in Pakistan
        //                    verificationCost = VerificationConfig.Cost_Postal_Local;
        //                    break;
        //                case false:
        //                    //is foreign
        //                    verificationCost = VerificationConfig.Cost_Postal_International;
        //                    break;
        //                default:
        //                    error = string.Format("No such option");
        //                    throw new Exception(error);
        //            }
        //            break;
        //        case MailServiceENUM.Courier:
        //            switch (CountryBiz.IsAddressInPakistan(avr.CountryId))
        //            {
        //                case true:
        //                    //is in Pakistan
        //                    verificationCost = VerificationConfig.Cost_Courier_Local;
        //                    break;
        //                case false:
        //                    verificationCost = VerificationConfig.Cost_Courier_International;
        //                    //is foreign
        //                    break;
        //                default:
        //                    error = string.Format("No such option");
        //                    throw new Exception(error);
        //            }
        //            break;
        //        default:
        //            error = string.Format("No such option: {0}", avr.MailServiceEnum);
        //            throw new Exception(error);
        //    }

        //    return verificationCost;
        //}


        public void IssueAddressVerificationRequest(AddressVerificationRequest avr, GlobalObject globalObject)
        {
            avr.AddressId.IsNullOrWhiteSpaceThrowArgumentException("id");

            if (avr.MailServiceEnum == MailServiceENUM.Unknown)
            {
                throw new Exception("Mail Service is unknown");
            }

            if (avr.IsSure1 == false)
            {
                throw new Exception("Not Sure 1");
            }

            if (avr.IsSure2 == false)
            {
                throw new Exception("Not Sure 2");
            }

            if (avr.PaymentAmount == 0)
            {
                throw new Exception("No payment amount.");
            }


            AddressMain address = Find(avr.AddressId);

            address.IsNullThrowException("Address Not found");

            AddressVerificationTrx addyVerfTrx = fixAddressVerificationTrx(avr, address);

            //this is where we give the verification number
            long verificationNumber = GenerateRandomVerificationNumber;

            addyVerfTrx.Verification.VerificationNumber = verificationNumber;



            if (address.AddressVerificationTrxs.IsNull())
            {
                address.AddressVerificationTrxs = new List <AddressVerificationTrx>();
            }

            address.AddressVerificationTrxs.Add(addyVerfTrx);
            address.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Requested;

            AddressVerificationTrxBiz.Create(addyVerfTrx);

            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

            param.Entity       = address as ICommonWithId;
            param.GlobalObject = globalObject;


            UpdateAndSave(param);

            //UpdateAndSave(address);
        }
Пример #2
0
        //this verifies the verification code and updates the AddressVerificationTrx and AddressWithId
        public void VerifiyAddressCode(AddressVerificationNumberVm avnVM, GlobalObject globalObject)
        {
            avnVM.IsNullThrowExceptionArgument("Address Verification not recieved");
            avnVM.VerificaitonNumber.IsNullOrWhiteSpaceThrowException("Verification is blank.");
            avnVM.AddressId.IsNullOrWhiteSpaceThrowException("Address Id not recieved");

            AddressMain address = Find(avnVM.AddressId);

            address.IsNullThrowException("Address not found");

            long lngVerificationNumber;
            bool success = long.TryParse(avnVM.VerificaitonNumber, out lngVerificationNumber);

            if (!success)
            {
                throw new Exception("Unable to read the verification number");
            }

            if (address.Verification.VerificationNumber != lngVerificationNumber)
            {
                throw new Exception("Verification number does not match!");
            }

            AddressVerificationTrx addressVerificationTrx = address
                                                            .AddressVerificationTrxs
                                                            .FirstOrDefault(x => x.Verification.VerificaionStatusEnum == EnumLibrary.EnumNS.VerificaionStatusENUM.Mailed);

            addressVerificationTrx.IsNullThrowException("Unable to locate Address Verification Trx");

            address.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Verified;
            addressVerificationTrx.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Verified;

            _addressVerificationTrxBiz.Update(addressVerificationTrx);


            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

            param.Entity       = address as ICommonWithId;
            param.GlobalObject = globalObject;


            UpdateAndSave(param);
        }
Пример #3
0
        AddressVerificationTrx fixAddressVerificationTrx(AddressVerificationRequest avr, AddressMain address)
        {
            address.Verification.SetTo(EnumLibrary.EnumNS.VerificaionStatusENUM.Requested);

            //create a Verification Request
            AddressVerificationTrx addyVerfTrx = AddressVerificationTrxBiz.Factory() as AddressVerificationTrx;

            //addyVerfTrx.Address = address;
            addyVerfTrx.AddressId       = avr.AddressId;
            addyVerfTrx.MailServiceEnum = avr.MailServiceEnum;
            //todo
            //addyVerfTrx.MailLocalOrForiegnEnum = GetMailLocalOrForiegnEnum(address.CountryId);

            //Accept payment here?
            addyVerfTrx.DateVerifcationPaymentAccepted = DateTime.UtcNow;

            addyVerfTrx.Verification.SetTo(VerificaionStatusENUM.Requested);
            addyVerfTrx.Name = string.Format("{0}-{1}", UserName, address.Name);

            return(addyVerfTrx);
        }
Пример #4
0
 void createAddressVerificationTrx(AddressMain address, AddressVerificationTrx addyVerfTrx)
 {
 }
Пример #5
0
        /// <summary>
        /// The goal is to make sure a duplicate verification request is not issued. All AddressVerificationTrx for the address that is be
        /// verified are brought without failure ones. If nothing is open, then verification can be issued.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override IQueryable <AddressVerificationTrx> GetDataToCheckDuplicateName(AddressVerificationTrx entity)
        {
            var allForAddress = FindAll().Where(x => x.AddressId == entity.AddressId);
            //Now we want to check if mailer has anything open for this address in proccess or other wise
            //only ones we do not care about are the ones that have failed.

            var dataToCheckForDuplicates = allForAddress.Where(x => x.Verification.VerificaionStatusEnum != VerificaionStatusENUM.Failed);

            return(dataToCheckForDuplicates);
        }