public static void SetAddress(string address, Address addr) { addr.Country = Globals.DefaultCountryID; addr.City = Globals.DefaultCity; addr.State = Globals.DefaultStateID; addr.PostalCode = Globals.DefaultZip; try { string[] parts = new string[3]; if (ParseAddress(address, out parts)) { addr.City = parts[0]; addr.PostalCode = parts[2]; addr.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID; } } catch { } }
private static CreateModel GetCreateModelFromBlue(C7_20tblLPPaymentInstructions investor) { CreateModel model = new CreateModel(); model.InvestorName = investor.FullName; model.Notes = investor.Comments; model.Alias = investor.Nameidentifier; // WARNING Blue has the following properties, but DeepBlue doesnt have these // investor.Reference; // WARNING: DeepBlue has the following properties, but Blue doesnt have, so we are using the default values model.DomesticForeign = true; model.EntityType = Globals.DefaultInvestorEntityTypeID; model.StateOfResidency = Globals.DefaultStateID; model.SocialSecurityTaxId = "123-23-1234"; model.Notes = Globals.DefaultString; #region Investor Address // WARNING: In Blue, there is no concept of an Investor Address, so we are setting default values here Address investorAddress = new Address(); investorAddress.Address1 = string.Empty; investorAddress.City = Globals.DefaultCity; investorAddress.Country = Globals.DefaultCountryID; investorAddress.PostalCode = Globals.DefaultZip; investorAddress.State = Globals.DefaultStateID; #endregion return model; }
public static List<DeepBlue.Models.Entity.Investor> ConvertBlueToDeepBlue() { Errors = new List<KeyValuePair<C7_20tblLPPaymentInstructions, Exception>>(); TotalConversionRecords = 0; RecordsConvertedSuccessfully = 0; List<DeepBlue.Models.Entity.Investor> dbInvestors = new List<DeepBlue.Models.Entity.Investor>(); using (BlueEntities context = new BlueEntities()) { List<C7_20tblLPPaymentInstructions> investors = context.C7_20tblLPPaymentInstructions.ToList(); foreach (C7_20tblLPPaymentInstructions investor in investors) { try { TotalConversionRecords++; DeepBlue.Models.Entity.Investor deepBlueInvestor = GetInvestorFromBlue(investor); #region Investor Account // Blue has only 1 account for 1 investor InvestorAccount account = new InvestorAccount(); if (!string.IsNullOrEmpty(investor.ABANumber)) { account.Routing = Convert.ToInt32(investor.ABANumber.Trim().Replace(" ", string.Empty).Replace("-", string.Empty)); } if (!string.IsNullOrEmpty(investor.AccountNumber)) { account.Account = investor.AccountNumber; } else { account.Account = Globals.DefaultStringValue; } account.AccountOf = investor.Accountof; account.Attention = investor.Attn; account.BankName = investor.Bank; account.Reference = investor.Reference; account.CreatedBy = Globals.CurrentUser.UserID; account.CreatedDate = DateTime.Now; account.EntityID = Globals.DefaultEntityID; account.IsPrimary = false; account.LastUpdatedBy = Globals.CurrentUser.UserID; account.LastUpdatedDate = DateTime.Now; // WARNING: The following values are present in our database, but not present in Blue, so setting those to NULL // FFC // FFCNO // IBAN // ByOrderOf // Swift #endregion deepBlueInvestor.InvestorAccounts.Add(account); #region Contact Info foreach (C7_25LPContactinfo contactInfo in investor.C7_25LPContactinfo) { InvestorContact investorContact = new InvestorContact(); investorContact.CreatedBy = Globals.CurrentUser.UserID; investorContact.CreatedDate = DateTime.Now; investorContact.EntityID = Globals.DefaultEntityID; investorContact.LastUpdatedBy = Globals.CurrentUser.UserID; investorContact.LastUpdatedDate = DateTime.Now; Contact contact = new Contact(); contact.ContactCompany = contactInfo.ContactCompany; contact.ContactName = contactInfo.ContactName; // WARNING: Deepblue has consolidated CallNotices/Distribution notices into one field. if (contactInfo.DistributionNotices != null) { contact.ReceivesDistributionNotices = contactInfo.DistributionNotices.Value; } if (contactInfo.Financials != null) { contact.ReceivesFinancials = contactInfo.Financials.Value; } if (contactInfo.InvestorLetters != null) { contact.ReceivesInvestorLetters = contactInfo.InvestorLetters.Value; } contact.CreatedBy = Globals.CurrentUser.UserID; contact.CreatedDate = DateTime.Now; contact.FirstName = contactInfo.ContactName; contact.LastName = "n/a"; contact.LastUpdatedBy = Globals.CurrentUser.UserID; contact.LastUpdatedDate = DateTime.Now; contact.EntityID = Globals.DefaultEntityID; investorContact.Contact = contact; // WARNING: We dont have the following values in our database // contactInfo.Dear; // This seems to be the first name from Contact Name Address contactAddress = new Address(); if (contactInfo.ContactAddress != null) { if (contactInfo.ContactAddress.Length > 40) { contactAddress.Address1 = contactInfo.ContactAddress.Substring(0, 40); } else { contactAddress.Address1 = contactInfo.ContactAddress; } } else { contactAddress.Address1 = Globals.DefaultStringValue; } //contactInfo.Comments; contactAddress.Address2 = contactInfo.ContactAddress2; // Contact Info(Access) doesnt have the values for these properties, so using default values contactAddress.Country = Globals.DefaultCountryID; contactAddress.City = Globals.DefaultCity; contactAddress.State = Globals.DefaultStateID; contactAddress.PostalCode = Globals.DefaultZip; try { string[] parts = new string[3]; if (ParseAddress(contactInfo.ContactAddress2, out parts)) { contactAddress.City = parts[0]; contactAddress.PostalCode = parts[2]; int postalCode = 0; bool validZip = true; if (Int32.TryParse(contactAddress.PostalCode, out postalCode)) { if (contactAddress.PostalCode.Length > 5) { validZip = false; } } else { validZip = false; } if (!validZip) { contactAddress.PostalCode = Globals.DefaultZip; } contactAddress.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID; } else { contactAddress.City = "dataerror: " + contactInfo.ContactAddress2; } } catch { } AddCommunication(contact, Models.Admin.Enums.CommunicationType.Email, contactInfo.ContactEmail); AddCommunication(contact, Models.Admin.Enums.CommunicationType.HomePhone, contactInfo.ContactPhone); AddCommunication(contact, Models.Admin.Enums.CommunicationType.Fax, contactInfo.ContactFax); contactAddress.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work; contactAddress.CreatedBy = Globals.CurrentUser.UserID; contactAddress.CreatedDate = DateTime.Now; contactAddress.EntityID = Globals.DefaultEntityID; contactAddress.LastUpdatedBy = Globals.CurrentUser.UserID; contactAddress.LastUpdatedDate = DateTime.Now; ContactAddress cntAddr = new ContactAddress(); cntAddr.CreatedBy = Globals.CurrentUser.UserID; cntAddr.CreatedDate = DateTime.Now; cntAddr.EntityID = Globals.DefaultEntityID; cntAddr.LastUpdatedBy = Globals.CurrentUser.UserID; cntAddr.LastUpdatedDate = DateTime.Now; cntAddr.Address = contactAddress; investorContact.Contact.ContactAddresses.Add(cntAddr); deepBlueInvestor.InvestorContacts.Add(investorContact); } #endregion dbInvestors.Add(deepBlueInvestor); RecordsConvertedSuccessfully++; } catch (Exception ex) { Errors.Add(new KeyValuePair<C7_20tblLPPaymentInstructions, Exception>(investor, ex)); } } } return dbInvestors; }
public static void ConvertInvestorViaWeb() { List<CreateModel> models = new List<CreateModel>(); using (BlueEntities context = new BlueEntities()) { List<C7_20tblLPPaymentInstructions> investors = context.C7_20tblLPPaymentInstructions.ToList(); foreach (C7_20tblLPPaymentInstructions investor in investors) { CreateModel model = GetCreateModelFromBlue(investor); #region Investor Account // Currently in blue, each investor has only one account model.AccountLength = 1; // This is used as a prefix for each InvestorAccount passed in the form //The following Key is used to determine if a particular Account has been deleted or not // index_BankIndex // index is 1 based InvestorAccount account = new InvestorAccount(); // Server looks for index_ABANumber account.Routing = Convert.ToInt32(investor.ABANumber); // Server looks for index_AccountNumber account.Account = investor.AccountNumber; account.AccountOf = investor.Accountof; account.Attention = investor.Attn; account.BankName = investor.Bank; account.Reference = investor.Reference; // WARNING: The following values are present in our database, but not present in Blue, so setting those to NULL // FFC // FFCNO // IBAN // ByOrderOf // Swift #endregion #region Contact Info //The following Key is used to determine if a particular Contact has been deleted or not // index_ContactIndex model.ContactLength = 0; foreach (C7_25LPContactinfo contactInfo in investor.C7_25LPContactinfo) { model.ContactLength++; Contact contact = new Contact(); contact.ContactCompany = contactInfo.ContactCompany; contact.ContactName = contactInfo.ContactName; // WARNING: Deepblue has consolidated CallNotices/Distribution notices into one field. if (contactInfo.DistributionNotices != null) { contact.ReceivesDistributionNotices = contactInfo.DistributionNotices.Value; } if (contactInfo.Financials != null) { contact.ReceivesFinancials = contactInfo.Financials.Value; } if (contactInfo.InvestorLetters != null) { contact.ReceivesInvestorLetters = contactInfo.InvestorLetters.Value; } // WARNING: We dont have the following values in our database // contactInfo.Dear; // This seems to be the first name from Contact Name Address contactAddress = new Address(); contactAddress.Address1 = contactInfo.ContactAddress; //contactInfo.Comments; contactAddress.Address2 = contactInfo.ContactAddress2; // Contact Info(Access) doesnt have the values for these properties, so using default values contactAddress.Country = Globals.DefaultCountryID; try { string[] parts = new string[3]; if (ParseAddress(contactInfo.ContactAddress2, out parts)) { contactAddress.City = parts[0]; contactAddress.PostalCode = parts[2]; contactAddress.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID; } } catch { contactAddress.City = Globals.DefaultCity; contactAddress.State = Globals.DefaultStateID; contactAddress.PostalCode = Globals.DefaultZip; } AddCommunication(contact, Models.Admin.Enums.CommunicationType.Email, contactInfo.ContactEmail); AddCommunication(contact, Models.Admin.Enums.CommunicationType.HomePhone, contactInfo.ContactPhone); AddCommunication(contact, Models.Admin.Enums.CommunicationType.Fax, contactInfo.ContactFax); } #endregion } } }
public ActionResult CreateScheduleK1(FormCollection collection) { ScheduleK1Model model=new ScheduleK1Model(); this.TryUpdateModel(model); IEnumerable<ErrorInfo> errorInfo=null; ResultModel resultModel=new ResultModel(); if(ModelState.IsValid) { PartnersShareForm scheduleK1; if(model.PartnersShareFormID>0) { scheduleK1=AdminRepository.FindScheduleK1((model.PartnersShareFormID??0)); } else { scheduleK1=new PartnersShareForm(); scheduleK1.CreatedBy=Authentication.CurrentUser.UserID; scheduleK1.CreatedDate=DateTime.Now; } scheduleK1.LastUpdatedBy=Authentication.CurrentUser.UserID; scheduleK1.LastUpdatedDate=DateTime.Now; scheduleK1.EntityID=Authentication.CurrentEntity.EntityID; scheduleK1.AlternativeMinimumTax=model.AlternativeMinimumTax; scheduleK1.BeginingCapital=model.BeginingCapital; scheduleK1.BeginingLoss=model.BeginingLoss; scheduleK1.BeginingProfit=model.BeginingProfit; scheduleK1.BeginningCapitalAccount=model.BeginningCapitalAccount; scheduleK1.CapitalContributed=model.CapitalContributed; scheduleK1.Collectibles28GainLoss=model.Collectibles28GainLoss; scheduleK1.Credits=model.Credits; scheduleK1.CurrentYearIncrease=model.CurrentYearIncrease; scheduleK1.Distribution=model.Distribution; scheduleK1.EndingCapital=model.EndingCapital; scheduleK1.EndingCapitalAccount=model.EndingCapitalAccount; scheduleK1.EndingLoss=model.EndingLoss; scheduleK1.EndingProfit=model.EndingProfit; scheduleK1.ForeignTransaction=model.ForeignTransaction; scheduleK1.FundID=model.FundID; scheduleK1.GuaranteedPayment=model.GuaranteedPayment; scheduleK1.InterestIncome=model.InterestIncome; scheduleK1.IRSCenter=model.IRSCenter; scheduleK1.IsDomesticPartner=model.IsDomesticPartner; scheduleK1.IsForeignPartner=model.IsForeignPartner; scheduleK1.IsGAAP=model.IsGAAP; scheduleK1.IsGain=model.IsGain; scheduleK1.IsGeneralPartner=model.IsGeneralPartner; scheduleK1.IsLimitedPartner=model.IsLimitedPartner; scheduleK1.IsOther=model.IsOther; scheduleK1.IsPTP=model.IsPTP; scheduleK1.IsSection704=model.IsSection704; scheduleK1.IsTaxBasis=model.IsTaxBasis; scheduleK1.NetLongTermCapitalGainLoss=model.NetLongTermCapitalGainLoss; scheduleK1.NetRentalRealEstateIncome=model.NetRentalRealEstateIncome; scheduleK1.NetSection1231GainLoss=model.NetSection1231GainLoss; scheduleK1.NetShortTermCapitalGainLoss=model.NetShortTermCapitalGainLoss; scheduleK1.NonRecourse=model.NonRecourse; scheduleK1.OrdinaryBusinessIncome=model.OrdinaryBusinessIncome; scheduleK1.OrdinaryDividends=model.OrdinaryDividends; scheduleK1.OtherDeduction=model.OtherDeduction; scheduleK1.OtherIncomeLoss=model.OtherIncomeLoss; scheduleK1.OtherInformation=model.OtherInformation; scheduleK1.OtherNetRentalIncomeLoss=model.OtherNetRentalIncomeLoss; scheduleK1.PartnerEIN=model.PartnerEIN; scheduleK1.PartnershipEIN=model.PartnershipEIN; scheduleK1.PartnerType=model.PartnerType; scheduleK1.QualifiedDividends=model.QualifiedDividends; scheduleK1.QualifiedNonRecourseFinancing=model.QualifiedNonRecourseFinancing; scheduleK1.Recourse=model.Recourse; scheduleK1.Royalties=model.Royalties; scheduleK1.Section179Deduction=model.Section179Deduction; scheduleK1.SelfEmploymentEarningLoss=model.SelfEmploymentEarningLoss; scheduleK1.TaxExemptIncome=model.TaxExemptIncome; scheduleK1.UnderlyingFundID=model.UnderlyingFundID; scheduleK1.UnrecapturedSection1250Gain=model.UnrecapturedSection1250Gain; scheduleK1.WithdrawalsAndDistributions=model.WithdrawalsAndDistributions; Address partnerAddress=null; if(model.PartnerAddressID>0) { partnerAddress=AdminRepository.FindAddress((model.PartnerAddressID??0)); } if(partnerAddress==null) { partnerAddress=new Address(); partnerAddress.CreatedBy=Authentication.CurrentUser.UserID; partnerAddress.CreatedDate=DateTime.Now; } partnerAddress.LastUpdatedBy=Authentication.CurrentUser.UserID; partnerAddress.LastUpdatedDate=DateTime.Now; partnerAddress.EntityID=Authentication.CurrentEntity.EntityID; partnerAddress.Address1=model.PartnerAddress1; partnerAddress.Address2=model.PartnerAddress2; partnerAddress.AddressTypeID=(int)DeepBlue.Models.Admin.Enums.AddressType.Work; partnerAddress.City=model.PartnerCity; partnerAddress.Country=model.PartnerCountry; partnerAddress.State=model.PartnerState; partnerAddress.PostalCode=model.PartnerZip; errorInfo=AdminRepository.SaveAddress(partnerAddress); if(errorInfo==null) { scheduleK1.PartnerAddressID=partnerAddress.AddressID; errorInfo=AdminRepository.SaveScheduleK1(scheduleK1); } if(errorInfo!=null) { foreach(var err in errorInfo.ToList()) { resultModel.Result+=err.PropertyName+" : "+err.ErrorMessage+"\n"; } } } else { foreach(var values in ModelState.Values.ToList()) { foreach(var err in values.Errors.ToList()) { if(string.IsNullOrEmpty(err.ErrorMessage)==false) { resultModel.Result+=err.ErrorMessage+"\n"; } } } } return View("Result",resultModel); }
private IEnumerable<ErrorInfo> Validate(Address address) { return ValidationHelper.Validate(address); }
private static DeepBlue.Models.Entity.UnderlyingFund GetUnderlyingFundFromBlue(C7_10tblGPPaymentInstructions blueUFund) { DeepBlue.Models.Entity.UnderlyingFund uf = new DeepBlue.Models.Entity.UnderlyingFund(); uf.EntityID = Globals.DefaultEntityID; // ToDO: IssuerID uf.FundName = blueUFund.Fund; uf.FundTypeID = GetFundType(blueUFund.FundType); uf.IsFeesIncluded = blueUFund.FeesInside.HasValue ? blueUFund.FeesInside.Value : false; uf.VintageYear = blueUFund.VintageYear.HasValue ? (short?)blueUFund.VintageYear : null; // TODO: Convert FundSize to money in DB and re-gen the model uf.TotalSize = Convert.ToInt32(blueUFund.FundSize); if (blueUFund.TerminationDate.HasValue) { uf.TerminationYear = Convert.ToInt16(blueUFund.TerminationDate.Value.Year); } // WARNING: these fields are present in blue but absent in deepblue // What are these fields used for in blue? //blueUFund.Website; //blueUFund.WebLogin; //blueUFund.WebPassword; uf.IndustryID = GetIndustryFocus(blueUFund.Industry_Focus); uf.GeographyID = Globals.Geograpies.First().GeographyID; uf.ReportingFrequencyID = GetReportingFrequency(blueUFund.Reporting); uf.ReportingTypeID = GetReportingType(blueUFund.ReportingType); uf.Description = Globals.DefaultString; Contact contact = new Contact(); contact.ContactName = blueUFund.ContactName; if (!string.IsNullOrEmpty(blueUFund.Phone)) { Communication comm = new Communication() { CommunicationTypeID = (int)DeepBlue.Models.Admin.Enums.CommunicationType.WorkPhone, CommunicationValue = blueUFund.Phone }; contact.ContactCommunications.Add(new ContactCommunication() { Communication = comm }); } if (!string.IsNullOrEmpty(blueUFund.Email_address)) { Communication comm = new Communication() { CommunicationTypeID = (int)DeepBlue.Models.Admin.Enums.CommunicationType.Email, CommunicationValue = blueUFund.Email_address }; contact.ContactCommunications.Add(new ContactCommunication() { Communication = comm }); } //uf.FundRegisteredOfficeID // TODO: use uf.FundRegisteredOfficeID to store the address Address address = new Address(); address.Address1 = blueUFund.MailingAddress1; address.Address2 = blueUFund.MailingAddress2; string[] parts = new string[3]; if (Util.ParseAddress(address.Address2, out parts)) { address.City = parts[0]; address.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID; address.PostalCode = parts[2]; } address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work; address.Country = Globals.DefaultCountryID; //ContactAddress contactAddress = new ContactAddress(); // contactAddress.Address = address; // contact.ContactAddresses.Add(contactAddress); Account account = new Account(); account.BankName = blueUFund.Bank; account.Routing = Convert.ToInt32(blueUFund.ABANumber.Replace("-", string.Empty).Replace(" ", string.Empty)); account.AccountOf = blueUFund.Accountof; account.Account1 = blueUFund.AccountNumber; account.Attention = blueUFund.Attn; account.Reference = blueUFund.Reference; // WARNING: the following fields are present in DeepBlue, but are not present in Blue //uf.LegalFundName //uf.FiscalYearEnd //uf.IsDomestic //uf.FundStructureId //uf.Taxable //uf.Exempt //uf.AddressID //uf.managementfee //uf.incentivefee //uf.taxrate //uf.auditorname //uf.managercontactid //uf.shareclasstypeid //uf.investmenttypeid //account.Phone; //account.Fax; //account.IBAN; //account.FFC; //account.FFCNumber; //account.SWIFT; //account.AccountNumberCash return uf; }
private static DeepBlue.Models.Entity.UnderlyingFund GetUnderlyingFundFromBlue(C7_10tblGPPaymentInstructions blueUFund, out Address fundRegisteredOffice) { DeepBlue.Models.Entity.UnderlyingFund uf = new DeepBlue.Models.Entity.UnderlyingFund(); uf.EntityID = Globals.DefaultEntityID; // ToDO: IssuerID uf.FundName = blueUFund.Fund; uf.FundTypeID = GetFundType(blueUFund.FundType); uf.IsFeesIncluded = blueUFund.FeesInside.HasValue ? blueUFund.FeesInside.Value : false; uf.VintageYear = blueUFund.VintageYear.HasValue ? (short?)blueUFund.VintageYear : null; // TODO: Convert FundSize to money in DB and re-gen the model try { uf.TotalSize = Convert.ToInt32(blueUFund.FundSize); } catch { uf.TotalSize = Int32.MaxValue; } if (blueUFund.TerminationDate.HasValue) { uf.TerminationYear = Convert.ToInt16(blueUFund.TerminationDate.Value.Year); } // WARNING: these fields are present in blue but absent in deepblue // What are these fields used for in blue? //blueUFund.Website; uf.GeographyID = Globals.Geograpies.First().GeographyID; // WARNING: We dont use the InvestmentTypeID. Do we really need this? // uf.InvestmentTypeID // ShareClass type can be added via the admin screen. However, we dont ask for it when creating a new UF. Should we not ask for it? // uf.ShareClassType // We dont use this field,a s there is no UI element for it. // uf.FundStructureID uf.WebUserName = blueUFund.WebLogin; uf.WebPassword = blueUFund.WebPassword; uf.IndustryID = GetIndustryFocus(blueUFund.Industry_Focus); uf.ReportingFrequencyID = GetReportingFrequency(blueUFund.Reporting); uf.ReportingTypeID = GetReportingType(blueUFund.ReportingType); uf.Description = Globals.DefaultString + blueUFund.Comments ?? string.Empty; // description cannot be over 100 characters if (uf.Description.Length > 100) { uf.Description = uf.Description.Substring(0, 100); } Contact contact = new Contact(); contact.ContactName = blueUFund.ContactName; if (!string.IsNullOrEmpty(blueUFund.Phone)) { Communication comm = new Communication() { CommunicationTypeID = (int)DeepBlue.Models.Admin.Enums.CommunicationType.WorkPhone, CommunicationValue = blueUFund.Phone }; contact.ContactCommunications.Add(new ContactCommunication() { Communication = comm }); } if (!string.IsNullOrEmpty(blueUFund.Email_address)) { Communication comm = new Communication() { CommunicationTypeID = (int)DeepBlue.Models.Admin.Enums.CommunicationType.Email, CommunicationValue = blueUFund.Email_address }; contact.ContactCommunications.Add(new ContactCommunication() { Communication = comm }); } if (!string.IsNullOrEmpty(contact.ContactName)) { uf.UnderlyingFundContacts.Add(new UnderlyingFundContact() { Contact = contact }); } //uf.FundRegisteredOfficeID // TODO: use uf.FundRegisteredOfficeID to store the address // This is the Fund's registered office address, and not the contact's address Address address = null; if (!string.IsNullOrEmpty(blueUFund.MailingAddress1) || !string.IsNullOrEmpty(blueUFund.MailingAddress2)) { address = new Address(); if (!string.IsNullOrEmpty(blueUFund.MailingAddress1)) { address.Address1 = blueUFund.MailingAddress1; } else { address.Address1 = Globals.DefaultStringValue; } // Address 1 has to be less than or equal to 40 characters if (address.Address1.Length > 40) { address.Address1 = address.Address1.Substring(0, 40); } address.Address2 = blueUFund.MailingAddress2; // Address 2 has to be less than or equal to 40 characters if (!string.IsNullOrEmpty(address.Address2) && address.Address2.Length > 40) { address.Address2 = address.Address2.Substring(0, 40); } //string[] parts = new string[3]; //if (Util.ParseAddress(address.Address2, out parts)) { // address.City = parts[0]; // address.State = Globals.States.Where(x => x.Abbr == parts[1].ToUpper().Trim()).First().StateID; // address.PostalCode = parts[2]; //} Util.SetAddress(address.Address2, address); address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work; address.Country = Globals.DefaultCountryID; } else { // We have to have the address.. The UI enforces us to have an address address = new Address(); address.Address1 = Globals.DefaultAddress1; address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work; address.City = Globals.DefaultCity; address.State = Globals.DefaultStateID; address.PostalCode = Globals.DefaultZip; address.Country = Globals.DefaultCountryID; messageLog.AppendLine("WARNING: " + uf.FundName + " doesnt have an address, so using default address"); } fundRegisteredOffice = address; // You have to have an account# for a successful account to be created if (!string.IsNullOrEmpty(blueUFund.AccountNumber)) { Account account = new Account(); account.BankName = blueUFund.Bank; try { account.Routing = Convert.ToInt32(blueUFund.ABANumber.Replace("-", string.Empty).Replace(" ", string.Empty)); } catch { account.Routing = 111000025; } account.AccountOf = blueUFund.Accountof; if (!string.IsNullOrEmpty(blueUFund.AccountNumber)) { account.Account1 = blueUFund.AccountNumber; } else { account.Account1 = "dummy_account"; } account.Attention = blueUFund.Attn; account.Reference = blueUFund.Reference; uf.Account = account; } // WARNING: the following fields are present in DeepBlue, but are not present in Blue //uf.LegalFundName uf.LegalFundName = uf.FundName; //uf.FiscalYearEnd //uf.IsDomestic //uf.FundStructureId //uf.Taxable //uf.Exempt //uf.AddressID //uf.managementfee //uf.incentivefee //uf.taxrate //uf.auditorname //uf.managercontactid //uf.shareclasstypeid //uf.investmenttypeid //account.Phone; //account.Fax; //account.IBAN; //account.FFC; //account.FFCNumber; //account.SWIFT; //account.AccountNumberCash return uf; }
private static int? CreateUnderlyingFund(CookieCollection cookies, DeepBlue.Models.Entity.UnderlyingFund underlyingFund, Address address, int? issuerId, ref int RecordsImportedSuccessfully, ref List<KeyValuePair<DeepBlue.Models.Entity.UnderlyingFund, Exception>> ImportErrors) { CreateUnderlyingFundModel model = new CreateUnderlyingFundModel(); model.IsFeesIncluded = underlyingFund.IsFeesIncluded; model.FundName = underlyingFund.FundName; model.FundTypeId = underlyingFund.FundTypeID; model.IssuerId = issuerId.Value; model.VintageYear = underlyingFund.VintageYear; model.TotalSize = underlyingFund.TotalSize; model.TerminationYear = underlyingFund.TerminationYear; model.IncentiveFee = underlyingFund.IncentiveFee; model.LegalFundName = underlyingFund.LegalFundName; model.Description = underlyingFund.Description; model.FiscalYearEnd = underlyingFund.FiscalYearEnd; model.ManagementFee = underlyingFund.ManagementFee; model.Taxable = underlyingFund.Taxable; model.TaxRate = underlyingFund.TaxRate; model.AuditorName = underlyingFund.AuditorName; model.IsDomestic = underlyingFund.IsDomestic; model.Exempt = underlyingFund.Exempt; model.IndustryId = underlyingFund.IndustryID; model.GeographyId = underlyingFund.GeographyID; model.ReportingFrequencyId = underlyingFund.ReportingFrequencyID; model.ReportingTypeId = underlyingFund.ReportingTypeID; // We dont use the ShareClass Type // model.ShareClassTypeId // We also dont use the InvestmentTypeId // model.InvestmentTypeId = underlyingFund.InvestmentTypeID; model.Description = underlyingFund.Description; model.FiscalYearEnd = underlyingFund.FiscalYearEnd; model.IsDomestic = underlyingFund.IsDomestic; model.FundStructureId = underlyingFund.FundStructureID; model.Taxable = underlyingFund.Taxable; model.Exempt = underlyingFund.Exempt; model.ManagementFee = underlyingFund.ManagementFee; model.IncentiveFee = underlyingFund.IncentiveFee; model.TaxRate = underlyingFund.TaxRate; model.AuditorName = underlyingFund.AuditorName; model.WebUserName = underlyingFund.WebUserName; model.WebPassword = underlyingFund.WebPassword; if (underlyingFund.Account != null) { model.BankName = underlyingFund.Account.BankName; model.ABANumber = underlyingFund.Account.Routing; model.AccountOf = underlyingFund.Account.AccountOf; model.AccountNumber = underlyingFund.Account.Account1; model.Account = underlyingFund.Account.Account1; model.Attention = underlyingFund.Account.Attention; model.Reference = underlyingFund.Account.Reference; } if (address != null) { model.Address1 = address.Address1; model.Address2 = address.Address2; model.City = address.City; model.Country = address.Country; model.State = address.State; model.Zip = address.PostalCode; } else { model.Address1 = Globals.DefaultStringValue; model.City = Globals.DefaultStringValue; model.Country = Globals.DefaultCountryID; model.State = Globals.DefaultStateID; model.Zip = Globals.DefaultZip; } string resp = string.Empty; int? underlyingFundId = CreateNewUnderlyingFund(cookies, model, out resp); if (underlyingFundId != null) { RecordsImportedSuccessfully++; string error = string.Empty; // Create the Contact // /Deal/CreateUnderlyingFundContact List<UnderlyingFundContact> contacts = underlyingFund.UnderlyingFundContacts.ToList(); foreach (UnderlyingFundContact ufContact in contacts) { ufContact.UnderlyingtFundID = underlyingFundId.Value; int? ufContactID = CreateUnderlyingFundContact(ufContact, cookies, out resp); if (ufContactID == null) { error += " Underlying Fund Contact could not be created. Response: " + resp; } } // Create the Address // /Deal/CreateUnderlyingFundAddress if (address != null) { CreateUnderlyingFundAddress(underlyingFundId.Value, address, cookies, out resp); if (!string.IsNullOrEmpty(resp)) { error += " Underlying Fund Address could not be created. Response: " + resp; } } if (!string.IsNullOrEmpty(error)) { ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.UnderlyingFund, Exception>(underlyingFund, new Exception("Underlying Fund was created, but the following errors were encountered: " + error))); } } else { ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.UnderlyingFund, Exception>(underlyingFund, new Exception("Underlying Fund Could not be created. Response: " + resp))); } return underlyingFundId; }
public static NameValueCollection CreateUnderlyingFundAddress(int underlyingFundId, Address address, CookieCollection cookies, out string resp) { resp = string.Empty; NameValueCollection values = new NameValueCollection(); UnderlyingFundAddressInformation registeredAddress = new UnderlyingFundAddressInformation(); registeredAddress.UnderlyingFundId = underlyingFundId; registeredAddress.Address1 = address.Address1; registeredAddress.Address2 = address.Address2; registeredAddress.City = address.City; registeredAddress.Country = address.Country; registeredAddress.State = address.State; registeredAddress.Zip = address.PostalCode; NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(registeredAddress, string.Empty, string.Empty); // Send the request string url = HttpWebRequestUtil.GetUrl("Deal/CreateUnderlyingFundAddress"); messageLog.AppendLine("Deal/CreateUnderlyingFundAddress"); string data = HttpWebRequestUtil.ToFormValue(formValues); messageLog.AppendLine("Form Data: " + data); byte[] postData = System.Text.Encoding.ASCII.GetBytes(data); HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies); if (response.StatusCode == System.Net.HttpStatusCode.OK) { using (Stream receiveStream = response.GetResponseStream()) { // Pipes the stream to a higher level stream reader with the required encoding format. using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { resp = readStream.ReadToEnd(); if (string.IsNullOrEmpty(resp)) { values = values.Combine(formValues); } else { } messageLog.AppendLine("Response: "+resp); response.Close(); readStream.Close(); } } } return values; }