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; }
private void UpdateContactCommunication(DeepBlueEntities context, Contact dealContact, Contact newDealContact) { EntityKey key; object originalItem; // Update contact communication foreach (var contactCommunication in dealContact.ContactCommunications) { key = default(EntityKey); originalItem = null; key = context.CreateEntityKey("ContactCommunications", contactCommunication); if (context.TryGetObjectByKey(key, out originalItem)) { context.ApplyCurrentValues(key.EntitySetName, contactCommunication); key = default(EntityKey); originalItem = null; key = context.CreateEntityKey("Communications", contactCommunication.Communication); if (context.TryGetObjectByKey(key, out originalItem)) { context.ApplyCurrentValues(key.EntitySetName, contactCommunication.Communication); } } else { Contact contact = null; if (newDealContact != null) { contact = newDealContact; } else { contact = context.ContactsTable.SingleOrDefault(cont => cont.ContactID == contactCommunication.Contact.ContactID); } if (contact != null) { contact.ContactCommunications.Add(new ContactCommunication { CreatedBy = contactCommunication.CreatedBy, CreatedDate = contactCommunication.CreatedDate, EntityID = contactCommunication.EntityID, LastUpdatedBy = contactCommunication.LastUpdatedBy, LastUpdatedDate = contactCommunication.LastUpdatedDate, Communication = new Communication { CommunicationComment = contactCommunication.Communication.CommunicationComment, CommunicationTypeID = contactCommunication.Communication.CommunicationTypeID, CommunicationValue = contactCommunication.Communication.CommunicationValue, CreatedBy = contactCommunication.Communication.CreatedBy, CreatedDate = contactCommunication.Communication.CreatedDate, EntityID = contactCommunication.Communication.EntityID, IsPreferred = contactCommunication.Communication.IsPreferred, LastFourPhone = contactCommunication.Communication.LastFourPhone, LastUpdatedBy = contactCommunication.Communication.LastUpdatedBy, LastUpdatedDate = contactCommunication.Communication.LastUpdatedDate, Listed = contactCommunication.Communication.Listed } }); } } } }
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 UpdateDealContact(FormCollection collection) { EditDealContactModel model=new EditDealContactModel(); ResultModel resultModel=new ResultModel(); IEnumerable<ErrorInfo> errorInfo=null; this.TryUpdateModel(model); string ErrorMessage=DealContactNameAvailable(model.ContactName,model.ContactId); if(String.IsNullOrEmpty(ErrorMessage)==false) { ModelState.AddModelError("ContactName",ErrorMessage); } if(ModelState.IsValid) { Contact contact=AdminRepository.FindContact(model.ContactId); if(contact==null) { contact=new Contact(); contact.CreatedBy=Authentication.CurrentUser.UserID; contact.CreatedDate=DateTime.Now; } contact.LastUpdatedBy=Authentication.CurrentUser.UserID; contact.LastUpdatedDate=DateTime.Now; contact.EntityID=Authentication.CurrentEntity.EntityID; contact.ContactName=model.ContactName; contact.LastName="n/a"; contact.Title=model.ContactTitle; contact.Notes=model.ContactNotes; AddCommunication(contact,Models.Admin.Enums.CommunicationType.Email,model.Email); AddCommunication(contact,Models.Admin.Enums.CommunicationType.HomePhone,model.Phone); AddCommunication(contact,Models.Admin.Enums.CommunicationType.WebAddress,model.WebAddress); errorInfo=AdminRepository.SaveDealContact(contact); resultModel.Result=ValidationHelper.GetErrorInfo(errorInfo); if(string.IsNullOrEmpty(resultModel.Result)) { resultModel.Result+="True||"+contact.ContactID.ToString(); } } 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 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 IEnumerable<ErrorInfo> Validate(Contact contact) { return ValidationHelper.Validate(contact); }