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); }
//public override void BusinessRulesFor(ModelsClassLibrary.ModelsNS.SharedNS.ControllerCreateEditParameter parm) //{ // base.BusinessRulesFor(parm); // Mailer mailer = parm.Entity as Mailer; // mailer.IsNullThrowException("Could not box mailer"); // mailer.Name.IsNullOrWhiteSpaceThrowException("mailer Name is empty"); //} public byte[] PrintVerificationLetters(string id) { //AddressVerificationModel_Header hdr = getVerificationLetterData(addressVerificationHdr); id.IsNullOrWhiteSpaceThrowException("id"); AddressVerificationHdr addressVerificationHdr = AddressVerificationHdrBiz.Find(id); addressVerificationHdr.IsNullThrowException("addressVerificationHdr"); addressVerificationHdr.Mailer.IsNullThrowException("Mailer"); //gather data string mailerName = addressVerificationHdr.Mailer.Name; string logoAddressAbsolute = System.Web.HttpContext.Current.Server.MapPath(MyConstants.LOGO_LOCATION); string addressMailFrom = CompanyConfig.CompanyAddress; string website = CompanyConfig.CompanyNameForWebPage; string userName = UserName; string printDate = DateTime.Now.ToShortDateString(); string letter_Instructions = VerificationConfig.Letter_Instruction_Para; string letter_welcomePara = VerificationConfig.Letter_Welcome_Para; string letter_body = VerificationConfig.Letter_Body; string letter_Title = VerificationConfig.Letter_Title; string sum_Title = VerificationConfig.Summary_Title; string sum_body = VerificationConfig.Summary_Body; string sum_Instructions = VerificationConfig.Summary_Instruction_Para; string sum_Welcome = VerificationConfig.Summary_Welcome_Para; //need to initialize string batchNumber = addressVerificationHdr.BatchNo.ToString(); MailLocalOrForiegnENUM mailLocalOrForiegnEnum = addressVerificationHdr.MailLocalOrForiegnEnum; MailServiceENUM mailServiceENUM = addressVerificationHdr.MailServiceEnum; byte[] hdr = createTheHeaderForPdfPrinting(addressVerificationHdr, mailerName, logoAddressAbsolute, addressMailFrom, website, userName, printDate, letter_Instructions, letter_welcomePara, letter_body, letter_Title, sum_Title, sum_body, sum_Instructions, sum_Welcome, batchNumber, mailLocalOrForiegnEnum, mailServiceENUM); return(hdr); }
public MailingCostsVM CreateMailingCostsVm(string addressVerificationHdrId) { addressVerificationHdrId.IsNullOrWhiteSpaceThrowArgumentException("addressVerificationHdrId"); AddressVerificationHdr addressVerificationHdr = AddressVerificationHdrBiz.Find(addressVerificationHdrId); addressVerificationHdr.IsNullThrowException(); MailingCostsVM mailingCostsVM = new MailingCostsVM(); mailingCostsVM.AddressVerificationHdr = addressVerificationHdr; mailingCostsVM.TotalLettersMailed = addressVerificationHdr.AddressVerificationTrxs.Count; mailingCostsVM.AddressVerificationHdrId = addressVerificationHdrId; return(mailingCostsVM); }
public void UpdateStatusToPrinted(string addressVerificationHdr_Id, GlobalObject globalObject) { addressVerificationHdr_Id.IsNullOrWhiteSpaceThrowArgumentException("addressVerificationHdr_Id"); AddressVerificationHdr addyVerfHdr = AddressVerificationHdrBiz.Find(addressVerificationHdr_Id); addyVerfHdr.IsNullThrowException("Address Veification Header not found. Status of transaction not changed."); addyVerfHdr.Verification.SetTo(VerificaionStatusENUM.Printed); ControllerCreateEditParameter param = new ControllerCreateEditParameter(); param.Entity = addyVerfHdr as ICommonWithId; param.GlobalObject = globalObject; AddressVerificationHdrBiz.UpdateAndSave(param); //updateAllTheAddresses(addyVerfHdr); //AddressVerificationHdrBiz.UpdateAndSave(addyVerfHdr); }