Exemple #1
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            Customer customer = Customer.Unbox(parm.Entity);

            //we need to add this because the DefaultBillAddressId is returning as a blank
            //and then thesystme thinks that there is a record with a blank Id
            //and the system does not save.

            //if (customer.DefaultInformToAddressId.IsNullOrWhiteSpace())
            //    customer.DefaultInformToAddressId = null;



            if (customer.CustomerCategoryId.IsNullOrWhiteSpace())
            {
                customer.CustomerCategoryId = null;
            }
            if (customer.DefaultInformToAddressId.IsNullOrWhiteSpace())
            {
                customer.DefaultInformToAddressId = null;
            }

            if (customer.Name.IsNullOrWhiteSpace())
            {
                customer.Name = UserName;
            }
        }
Exemple #2
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            LikeUnlike likeUnlike = parm.Entity as LikeUnlike;

            if (likeUnlike.MenuPath1Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath1Id = null;
            }

            if (likeUnlike.MenuPath2Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath2Id = null;
            }

            if (likeUnlike.MenuPath3Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath3Id = null;
            }

            if (likeUnlike.ProductId.IsNullOrWhiteSpace())
            {
                likeUnlike.ProductId = null;
            }

            if (likeUnlike.PersonId.IsNullOrWhiteSpace())
            {
                likeUnlike.PersonId = null;
            }
        }
Exemple #3
0
        public override void BusinessRulesFor(ControllerCreateEditParameter parm)
        {
            MenuPathMain mpm = parm.Entity as MenuPathMain;

            base.BusinessRulesFor(parm);
            _menuPathMainBiz.BusinessRulesFor(parm);
        }
Exemple #4
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("User is not logged in");
            CashTrx paymentTrx = parm.Entity as CashTrx;

            paymentTrx.IsNullThrowException("Unable to unbox payment trx");


            if (paymentTrx.DocNumber == 0)
            {
                paymentTrx.DocNumber = GetNextDocNumber();
            }

            if (parm.Entity.Name.IsNullOrWhiteSpace())
            {
                parm.Entity.Name = UserName;
                parm.Entity.Name = parm.Entity.MakeUniqueName();
            }

            if (paymentTrx.PersonFromId.IsNullOrEmpty())
            {
                paymentTrx.PersonFromId = null;
            }

            paymentTrx.PersonToId.IsNullOrWhiteSpaceThrowException("You must declare who you are paying.");

            Person personTo = PersonBiz.Find(paymentTrx.PersonToId);

            personTo.IsNullThrowException("personTo");
            paymentTrx.PersonTo = personTo;

            base.Fix(parm);
        }
Exemple #5
0
 private void fix_MenuManager(BuySellDoc buySellDoc, ControllerCreateEditParameter parm)
 {
     if (buySellDoc.MenuManager.IsNull())
     {
         buySellDoc.MenuManager = new MenuManager(null, null, null, MenuENUM.IndexDefault, BreadCrumbManager, null, UserId, parm.ReturnUrl, UserName);
     }
 }
Exemple #6
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            PenaltyTrx penaltyTrx = PenaltyTrx.Unbox(parm.Entity);

            fix_Name(penaltyTrx);
        }
Exemple #7
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("User is not logged in");
            BuySellDoc bsd = BuySellDoc.UnBox(parm.Entity);


            fixDocumentNumber(bsd);
            fixName(parm);
            fixCustomer(bsd);
            fixSeller(bsd);

            fixCustomerSalesman(bsd);
            fix_Super_Customer_Salesman(bsd);
            fix_Super_Super_Customer_Salesman(bsd);

            fixOwnerSalesman(bsd);
            fix_Super_Owner_Salesman(bsd);
            fix_Super_Super_Owner_Salesman(bsd);


            fixDeliverymanSalesman(bsd);
            fix_Super_Deliveryman_Salesman(bsd);
            fix_Super_Super_Deliveryman_Salesman(bsd);

            fixAddresses(bsd);
            fixVehicalType(bsd);
            fixFreight(bsd);
            fixDate(bsd);
            fixFreightOfferTrxId(bsd);
            fix_Update_BuySellDocStateModifierEnum_InBuySell(parm, bsd);
            fix_MenuManager(bsd, parm);

            fix_OptedOutOfSystem(bsd);
            base.Fix(parm);
        }
Exemple #8
0
 private static void fixName(ControllerCreateEditParameter parm)
 {
     if (parm.Entity.Name.IsNullOrWhiteSpace())
     {
         parm.Entity.Name = parm.Entity.MakeUniqueName();
     }
 }
Exemple #9
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            Mailer mailer = Mailer.Unbox(parm.Entity);

            if (mailer.DefaultBillAddressId.IsNullOrWhiteSpace())
            {
                mailer.DefaultBillAddressId = null;
            }

            if (mailer.DefaultShipAddressId.IsNullOrWhiteSpace())
            {
                mailer.DefaultShipAddressId = null;
            }

            //update the User as well.
            //mailer.UserId.IsNullOrWhiteSpaceThrowArgumentException("No user ID");
            //locate User

            //we cannot send the logged in user's Id when creating a mailer, we need to send in the
            //mailers UserId, especially during create

            //ApplicationUser mailerUser = UserBiz.Find(mailer.UserId);
            //mailerUser.IsNullThrowException("User for Mailer not found");

            //dont do this!! This causes terrible errors of data concurrency etc. Entity Framwork will do this
            //mailer.User = mailerUser;
            //mailer.Name = mailerUser.UserName;
        }
Exemple #10
0
        public bool CheckEmailVerificationCode(string emailAddressId, string verificationCode, GlobalObject globalObject)
        {
            UserId.IsNullThrowException("You are not logged in");
            emailAddressId.IsNullOrWhiteSpaceThrowArgumentException("emailAddressId");
            verificationCode.IsNullOrWhiteSpaceThrowArgumentException("verificationCode");

            EmailAddress emailAddress = Find(emailAddressId);

            emailAddress.IsNullThrowException("Email not found");
            if (emailAddress.VerificationNumber == verificationCode)
            {
                //verification code matches... verifiy the email address
                //emailAddress.IsVerified = true;
                emailAddress.VerificationDateComplex.SetToTodaysDate(UserName, UserId);
                emailAddress.VerificationStatusEnum = VerificaionStatusENUM.Verified;
                emailAddress.VerificationDateComplex.SetToTodaysDate(UserName, UserId);


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

                UpdateAndSave(param);


                ErrorsGlobal.AddMessage(string.Format("Email: '{0} has been VERIFIED'", emailAddress.Name));
                return(true);
            }

            ErrorsGlobal.AddMessage(string.Format("Email: '{0}' -VERIFICATION FAILED!", emailAddress.Name));
            return(false);
        }
Exemple #11
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            ServiceRequestHdr srh = ServiceRequestHdr.Unbox(parm.Entity);

            fixName(srh);
            base.Fix(parm);
            addDocumentNumber(srh);
        }
Exemple #12
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            PenaltyHeader penaltyHeader = PenaltyHeader.Unbox(parm.Entity);

            addDocumentNumber(penaltyHeader);
            fixName(penaltyHeader);
        }
Exemple #13
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);
        }
Exemple #14
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);

            Right right = parm.Entity as Right;

            fixId(right);
            fixName(right);
        }
        public override void Fix(ControllerCreateEditParameter parm)
        {
            BuySellDocHistory buySellDocHistory = BuySellDocHistory.UnBox(parm.Entity);

            if (buySellDocHistory.Name.IsNullOrWhiteSpace())
            {
                buySellDocHistory.Name = buySellDocHistory.MakeUniqueName();
            }
        }
Exemple #16
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            MenuPathMain mpm = new MenuPathMain();

            mpm = parm.Entity as MenuPathMain;
            getMenuPaths(mpm);
            fixName(mpm);
        }
Exemple #17
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            AddressMain addy = parm.Entity as AddressMain;

            AttachCountry(addy);
            addy.Name = parm.Entity.MakeUniqueName();
            addy.VerificationStatusEnum = addy.Verification.VerificaionStatusEnum;
        }
Exemple #18
0
        private void fix_Update_BuySellDocStateModifierEnum_InBuySell(ControllerCreateEditParameter parm, BuySellDoc buySellDoc)
        {
            //Only fix the value if it has no value. This is because sometimes it gets the value from Edit, and other times
            //from Specific Methods in the Controller like CancelRejectOrder.

            if (buySellDoc.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Unknown)
            {
                buySellDoc.BuySellDocStateModifierEnum = parm.BuySellDocStateModifierEnum;
            }
        }
        public void UpdateAndSaveMailingCost(MailingCostsVM mailingCostsVM, GlobalObject globalObject)
        {
            mailingCostsVM.AddressVerificationHdrId.IsNullOrWhiteSpaceThrowArgumentException("View has lost the AddressVerificationHdrId");

            AddressVerificationHdr addressVerificationHdr = AddressVerificationHdrBiz.Find(mailingCostsVM.AddressVerificationHdrId);

            addressVerificationHdr.IsNullThrowException("AddressVerificationHdr not found.");

            if (mailingCostsVM.Cost == 0)
            {
                throw new Exception("Mailing cost cannot be 0. Please try again.");
            }

            if (mailingCostsVM.TotalLettersMailed == 0)
            {
                throw new Exception("Total letters mailed cannot be 0. Try again.");
            }

            if (mailingCostsVM.TotalLettersMailed < addressVerificationHdr.AddressVerificationTrxs.Count)
            {
                ErrorsGlobal.AddMessage("You have left over letters. Please go to Letter Cancelation screen");
            }

            if (mailingCostsVM.TotalLettersMailed > addressVerificationHdr.AddressVerificationTrxs.Count)
            {
                ErrorsGlobal.AddMessage("You cannot mail more letters than you have! Please try again");
            }


            //update fields
            addressVerificationHdr.TotalQtyLettersMailed = mailingCostsVM.TotalLettersMailed;
            addressVerificationHdr.BudgetedCost          =
                mailingCostsVM.TotalLettersMailed *
                MailerBiz.GetBugetedCost(addressVerificationHdr.MailLocalOrForiegnEnum, addressVerificationHdr.MailServiceEnum);

            addressVerificationHdr.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Mailed;
            addressVerificationHdr.Verification.MailedDate.SetToTodaysDate(UserName, UserId);

            //update all the children to mailed.
            addressVerificationHdr.AddressVerificationTrxs.IsNullOrEmptyThrowException("There are no letters");
            foreach (AddressVerificationTrx letter in addressVerificationHdr.AddressVerificationTrxs)
            {
                letter.Verification.VerificaionStatusEnum = VerificaionStatusENUM.Mailed;
                letter.Verification.MailedDate.SetToTodaysDate(UserName, UserId);
                AddressVerificationTrxBiz.Update(letter);
            }

            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

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

            AddressVerificationHdrBiz.UpdateAndSave(param);
        }
        private void set_Payment_For_Deliveryman(BuySellDoc bsd, ControllerCreateEditParameter parm)
        {
            decimal currBalance_NonRefundable = parm.GlobalObject.Money_User.Non_Refundable.MoneyAmount;
            decimal currBalance_Refundable    = parm.GlobalObject.Money_User.Refundable.MoneyAmount;

            decimal commissionAmount_Refundable = SalesCommissionClass.TotalCommissionOnFreight_Amount(bsd.Freight_Accepted_Refundable);

            IsEnoughBalanceForUser(bsd, parm, commissionAmount_Refundable, 0);

            bsd.Total_Delivery_Payment_For_Invoice.Amount_Refundable = commissionAmount_Refundable;
        }
Exemple #21
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            State state = parm.Entity as State;

            if (!state.Abbreviation.IsNullOrWhiteSpace())
            {
                state.Abbreviation = state.Abbreviation.ToUpper();
            }

            //fixTheCountry(state);
        }
Exemple #22
0
        private void addUploadFileLocation(ControllerCreateEditParameter parm)
        {
            //check if a Misc File is uploaded.
            if (parm.MiscUploadedFiles.IsNull())
            {
                return;
            }

            FileDoc fd = parm.Entity as FileDoc;

            parm.MiscUploadedFiles.FileLocationConst = fd.MiscFilesLocation_Initialization();
        }
        public override void Fix(ControllerCreateEditParameter parm)
        {
            //This uses the following fields to make the name
            // Rule
            // Type
            // UserName (If User is not null, o/w it leaves user out)
            DiscountPrecedence dp = parm.Entity as DiscountPrecedence;

            dp.Name = dp.FixNameFor(dp);
            //putCurrentPrecedenceInLastRank(entity);
            base.Fix(parm);
        }
        /// <summary>
        /// I changed from CreateSimple to Create... there may be a mess here,
        /// </summary>
        /// <param name="parm"></param>
        public override void CreateSimple(ControllerCreateEditParameter parm)
        {
            DiscountPrecedence dp = parm.Entity as DiscountPrecedence;

            if (dp.DiscountRuleEnum == DiscountRuleENUM.Unknown || dp.DiscountTypeEnum == DiscountTypeENUM.Unknown)
            {
                return;
            }


            base.Create(parm);
        }
Exemple #25
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            Person person = parm.Entity as Person;

            person.IsNullThrowException("Unable to unbox person");

            //we need to add this because the DefaultBillAddressId is returning as a blank
            //and then thesystme thinks that there is a record with a blank Id
            //and the system does not save.
            if (person.DefaultBillAddressId.IsNullOrWhiteSpace())
            {
                person.DefaultBillAddressId = null;
            }

            if (person.PersonCategoryId.IsNullOrWhiteSpace())
            {
                person.PersonCategoryId = null;
            }

            if (person.CountryId.IsNullOrWhiteSpace())
            {
                person.CountryId = null;
            }

            if (person.DefaultEmailAddressId.IsNullOrWhiteSpace())
            {
                person.DefaultEmailAddressId = null;
            }

            if (person.DefaultPhoneId.IsNullOrWhiteSpace())
            {
                person.DefaultPhoneId = null;
            }

            //if (person.Users.IsNullOrEmpty())
            //{
            //    person.Name = UserName;

            //    person.Users = new List<ApplicationUser>();
            //    ApplicationUser appUser = UserBiz.Find(UserId);
            //    appUser.IsNullThrowException("User");

            //    //if (!appUser.PersonId.IsNullOrWhiteSpace())
            //    //    throw new Exception("User has a person, but person is not recognizing the user! Programming Error.");

            //    appUser.PersonId = person.Id;
            //    person.Users.Add(appUser);
            //    UserBiz.Update(appUser);
            //}
        }
Exemple #26
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in.");
            base.Fix(parm);
            TEntity entity = parm.Entity as TEntity;

            entity.IsNullThrowException("Unable to unbox email");

            if (entity.PersonId.IsNullOrWhiteSpace())
            {
                string personId = GetPersonIdForCurrentUser();
                entity.PersonId = personId;
            }
        }
Exemple #27
0
        public override void ErrorCheck(ControllerCreateEditParameter parm)
        {
            base.ErrorCheck(parm);

            ProductChild productChild = parm.Entity as ProductChild;

            //address should exist.
            productChild.ShipFromAddressComplex.ErrorCheck();

            if (!productChild.ShipFromAddressComplex.Error.IsNullOrWhiteSpace())
            {
                throw new Exception(productChild.ShipFromAddressComplex.Error);
            }
        }
Exemple #28
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            parm.Entity.Name = parm.Entity.Name.ToTitleCase();

            FileDoc fileDoc = parm.Entity as FileDoc;

            fileDoc.IsNullThrowException("Unable to unbox file doc.");
            if (fileDoc.PersonId.IsNullOrWhiteSpace())
            {
                attachPerson(fileDoc);
            }

            addUploadFileLocation(parm);
        }
Exemple #29
0
        public void UpdateAndSaveDefaultAddress(string userId, string addressId, GlobalObject globalObject)
        {
            userId.IsNullOrWhiteSpaceThrowArgumentException("userId");
            addressId.IsNullOrWhiteSpaceThrowArgumentException("AddressId is null");

            AddressMain address = Find(addressId);

            address.IsNullThrowException("Address");

            //the default address must always be all three
            if (!address.AddressType.IsBillAddress || !address.AddressType.IsShipAddress || !address.AddressType.IsInformAddress)
            {
                if (!address.AddressType.IsBillAddress)
                {
                    ErrorsGlobal.AddMessage("Updated to Billing address.");
                }

                if (!address.AddressType.IsShipAddress)
                {
                    ErrorsGlobal.AddMessage("Updated to Shipping address.");
                }

                if (!address.AddressType.IsInformAddress)
                {
                    ErrorsGlobal.AddMessage("Updated to Inform To address.");
                }

                address.AddressType.IsBillAddress   = true;
                address.AddressType.IsShipAddress   = true;
                address.AddressType.IsInformAddress = true;
                Update(address);
            }

            Person person = UserBiz.GetPersonFor(userId);

            person.IsNullThrowException("Person not found");

            person.DefaultBillAddressId = addressId;

            ControllerCreateEditParameter param = new ControllerCreateEditParameter();

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

            PersonBiz.UpdateAndSave(param);

            //PersonBiz.UpdateAndSave(person);
        }
Exemple #30
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            //this does not work here because we need to update the number of visits and that can be by anyone.
            //You must be logged in
            //UserId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in.");

            Product product = parm.Entity as Product;

            product.IsNullThrowException("Unable to unbox product");


            if (product.UomDimensionsId.IsNullOrWhiteSpace())
            {
                product.UomDimensionsId = null;
            }

            if (product.UomPurchaseId.IsNullOrWhiteSpace())
            {
                product.UomPurchaseId = null;
            }

            if (product.UomSaleId.IsNullOrWhiteSpace())
            {
                product.UomSaleId = null;
            }


            if (product.UomVolumeId.IsNullOrWhiteSpace())
            {
                product.UomVolumeId = null;
            }


            if (product.UomWeightActualId.IsNullOrWhiteSpace())
            {
                product.UomWeightActualId = null;
            }

            if (product.UomWeightListedId.IsNullOrWhiteSpace())
            {
                product.UomWeightListedId = null;
            }

            if (product.OwnerId.IsNullOrWhiteSpace())
            {
                product.OwnerId = null;
            }
        }