コード例 #1
0
ファイル: InvestorController.cs プロジェクト: jsingh/DeepBlue
 //
 // GET: /Investor/New
 public ActionResult New()
 {
     ViewData["MenuName"] = "InvestorManagement";
     ViewData["SubmenuName"] = "NewInvestorSetup";
     ViewData["PageName"] = "New Investor Setup";
     CreateModel model = new CreateModel();
     model.InvestorEntityTypes = SelectListFactory.GetInvestorEntityTypesSelectList(AdminRepository.GetAllInvestorEntityTypes());
     //model.SelectList.AddressTypes = SelectListFactory.GetAddressTypeSelectList(AdminRepository.GetAllAddressTypes());
     model.DomesticForeigns = SelectListFactory.GetDomesticForeignList();
     model.Sources = SelectListFactory.GetSourceList();
     model.CustomField = new CustomFieldModel();
     model.CustomField.Fields = AdminRepository.GetAllCustomFields((int)DeepBlue.Models.Admin.Enums.Module.Investor);
     model.CustomField.Values = new List<CustomFieldValueDetail>();
     model.DomesticForeign = true;
     model.AccountLength = 0;
     model.ContactLength = 0;
     model.Country = (int)DeepBlue.Models.Admin.Enums.DefaultCountry.USA;
     model.CountryName = "United States";
     return View(model);
 }
コード例 #2
0
ファイル: InvestorController.cs プロジェクト: jsingh/DeepBlue
        public ActionResult Create(FormCollection collection)
        {
            CreateModel model = new CreateModel();
            ResultModel resultModel = new ResultModel();
            IEnumerable<ErrorInfo> errorInfo = null;
            this.TryUpdateModel(model);
            string ErrorMessage = InvestorNameAvailable(model.InvestorName, model.InvestorId);
            StringBuilder errors;
            EmailAttribute emailValidation = new EmailAttribute();
            ZipAttribute zipAttribute = new ZipAttribute();
            WebAddressAttribute webAttribute = new WebAddressAttribute();
            int count = 0;
            string errorTitle = string.Empty;
            if (String.IsNullOrEmpty(ErrorMessage) == false) {
                ModelState.AddModelError("InvestorName", ErrorMessage);
            }
            ErrorMessage = SocialSecurityTaxIdAvailable(model.SocialSecurityTaxId, model.InvestorId);
            if (String.IsNullOrEmpty(ErrorMessage) == false) {
                ModelState.AddModelError("SocialSecurityTaxId", ErrorMessage);
            }
            if (ModelState.IsValid) {
                // Attempt to create new deal.
                DeepBlue.Models.Entity.Investor investor = new DeepBlue.Models.Entity.Investor();
                investor.Alias = model.Alias;
                investor.IsDomestic = model.DomesticForeign;
                investor.InvestorEntityTypeID = model.EntityType;
                investor.InvestorName = model.InvestorName;
                investor.FirstName = model.Alias;
                investor.ResidencyState = model.StateOfResidency;
                investor.Social = model.SocialSecurityTaxId ?? "";
                investor.Notes = model.Notes;
                investor.Source = model.Source;
                investor.FOIA = model.FOIA;
                investor.ERISA = model.ERISA;

                investor.TaxID = 0;
                investor.FirstName = string.Empty;
                investor.LastName = "n/a";
                investor.ManagerName = string.Empty;
                investor.MiddleName = string.Empty;
                investor.PrevInvestorID = 0;
                investor.CreatedBy = Authentication.CurrentUser.UserID;
                investor.CreatedDate = DateTime.Now;
                investor.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investor.LastUpdatedDate = DateTime.Now;
                investor.EntityID = Authentication.CurrentEntity.EntityID;
                investor.TaxExempt = false;

                // Attempt to create new investor address.
                InvestorAddress investorAddress = new InvestorAddress();
                investorAddress.CreatedBy = Authentication.CurrentUser.UserID;
                investorAddress.CreatedDate = DateTime.Now;
                investorAddress.EntityID = Authentication.CurrentEntity.EntityID;
                investorAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorAddress.LastUpdatedDate = DateTime.Now;

                investorAddress.Address = new Address();
                investorAddress.Address.Address1 = model.Address1 ?? "";
                investorAddress.Address.Address2 = model.Address2 ?? "";
                investorAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                investorAddress.Address.City = model.City ?? "";
                investorAddress.Address.Country = model.Country;
                investorAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                investorAddress.Address.CreatedDate = DateTime.Now;
                investorAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                investorAddress.Address.LastUpdatedDate = DateTime.Now;
                investorAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                investorAddress.Address.PostalCode = model.Zip;
                investorAddress.Address.State = model.State;

                if (string.IsNullOrEmpty(investorAddress.Address.Address1) == false
                    || string.IsNullOrEmpty(investorAddress.Address.Address2) == false
                    || string.IsNullOrEmpty(investorAddress.Address.City) == false
                    || string.IsNullOrEmpty(investorAddress.Address.PostalCode) == false
                    || string.IsNullOrEmpty(investorAddress.Address.County) == false
                    || string.IsNullOrEmpty(model.Phone) == false
                    || string.IsNullOrEmpty(model.Email) == false
                    || string.IsNullOrEmpty(model.WebAddress) == false
                    || string.IsNullOrEmpty(model.Fax) == false
                    ) {

                    errorTitle = "<b>Address Information:</b>";
                    errors = new StringBuilder();
                    errorInfo = ValidationHelper.Validate(investorAddress.Address);
                    if (errorInfo.Any()) {
                        errors.Append(ValidationHelper.GetErrorInfo(errorInfo));
                    }
                    if (emailValidation.IsValid(model.Email) == false)
                        errors.Append("Invalid Email\n");
                    if (zipAttribute.IsValid(model.Zip) == false)
                        errors.Append("Invalid Zip\n");
                    if (webAttribute.IsValid(model.WebAddress) == false)
                        errors.Append("Invalid Web Address\n");
                    if (string.IsNullOrEmpty(errors.ToString()) == false) {
                        resultModel.Result = string.Format("{0}\n{1}\n", errorTitle, errors.ToString());
                    }

                    if (string.IsNullOrEmpty(resultModel.Result)) {
                        /* Add New Investor Address */
                        investor.InvestorAddresses.Add(investorAddress);
                        /* Investor Communication Values */
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.HomePhone, model.Phone);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.Email, model.Email);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.WebAddress, model.WebAddress);
                        AddCommunication(investor, Models.Admin.Enums.CommunicationType.Fax, model.Fax);
                    }
                }

                /* Bank Account */
                count = 0;
                InvestorAccount investorAccount;
                for (int index = 0; index < model.AccountLength; index++) {

                    if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "BankIndex"]) <= 0) continue;

                    count++;

                    // Attempt to create new investor account.
                    investorAccount = new InvestorAccount();
                    investorAccount.Comments = string.Empty;
                    investorAccount.CreatedBy = Authentication.CurrentUser.UserID;
                    investorAccount.CreatedDate = DateTime.Now;
                    investorAccount.EntityID = Authentication.CurrentEntity.EntityID;
                    investorAccount.IsPrimary = false;
                    investorAccount.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorAccount.LastUpdatedDate = DateTime.Now;
                    investorAccount.Routing = DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ABANumber"]);
                    investorAccount.Reference = Convert.ToString(collection[(index + 1).ToString() + "_" + "Reference"]);
                    investorAccount.AccountOf = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountOf"]);
                    investorAccount.FFC = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFC"]);
                    investorAccount.FFCNumber = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFCNumber"]);
                    investorAccount.IBAN = Convert.ToString(collection[(index + 1).ToString() + "_" + "IBAN"]);
                    investorAccount.ByOrderOf = Convert.ToString(collection[(index + 1).ToString() + "_" + "ByOrderOf"]);
                    investorAccount.SWIFT = Convert.ToString(collection[(index + 1).ToString() + "_" + "Swift"]);
                    investorAccount.Account = Convert.ToString(collection[(index + 1).ToString() + "_" + "Account"]);
                    investorAccount.AccountNumberCash = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountNumber"]);
                    investorAccount.Attention = Convert.ToString(collection[(index + 1).ToString() + "_" + "Attention"]);
                    investorAccount.BankName = Convert.ToString(collection[(index + 1).ToString() + "_" + "BankName"]);
                    investorAccount.Phone = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountPhone"]);
                    investorAccount.Fax = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountFax"]);

                    if (string.IsNullOrEmpty(investorAccount.Comments) == false
                      || string.IsNullOrEmpty(investorAccount.Reference) == false
                      || string.IsNullOrEmpty(investorAccount.AccountOf) == false
                      || string.IsNullOrEmpty(investorAccount.FFC) == false
                      || string.IsNullOrEmpty(investorAccount.FFCNumber) == false
                      || string.IsNullOrEmpty(investorAccount.IBAN) == false
                      || string.IsNullOrEmpty(investorAccount.ByOrderOf) == false
                      || string.IsNullOrEmpty(investorAccount.SWIFT) == false
                      || string.IsNullOrEmpty(investorAccount.Account) == false
                      || string.IsNullOrEmpty(investorAccount.AccountNumberCash) == false
                      || string.IsNullOrEmpty(investorAccount.Attention) == false
                      || string.IsNullOrEmpty(investorAccount.BankName) == false
                      || string.IsNullOrEmpty(investorAccount.Phone) == false
                      || string.IsNullOrEmpty(investorAccount.Fax) == false
                      || investorAccount.Routing > 0) {
                        errorInfo = ValidationHelper.Validate(investorAccount);
                        if (errorInfo.Any()) {
                            resultModel.Result += string.Format("<b>Bank Information {0}:</b>\n{1}\n", count.ToString(), ValidationHelper.GetErrorInfo(errorInfo));
                        }
                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investor.InvestorAccounts.Add(investorAccount);
                        }
                    }
                }

                count = 0;
                /* Contact Address */
                InvestorContact investorContact;
                ContactAddress contactAddress;
                for (int index = 0; index < model.ContactLength; index++) {

                    if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ContactIndex"]) <= 0) continue;

                    count++;

                    // Attempt to create new investor contact.
                    investorContact = new InvestorContact();
                    investorContact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.CreatedDate = DateTime.Now;
                    investorContact.EntityID = Authentication.CurrentEntity.EntityID;
                    investorContact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorContact.LastUpdatedDate = DateTime.Now;
                    investorContact.Contact = new Contact();

                    investorContact.Contact.ContactName = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactPerson"]);
                    investorContact.Contact.CreatedBy = Authentication.CurrentUser.UserID;
                    investorContact.Contact.CreatedDate = DateTime.Now;
                    investorContact.Contact.FirstName = "n/a";
                    investorContact.Contact.LastName = "n/a";
                    investorContact.Contact.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    investorContact.Contact.LastUpdatedDate = DateTime.Now;
                    investorContact.Contact.ReceivesDistributionNotices = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "DistributionNotices"]);
                    investorContact.Contact.ReceivesFinancials = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "Financials"]);
                    investorContact.Contact.ReceivesInvestorLetters = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "InvestorLetters"]);
                    investorContact.Contact.ReceivesK1 = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "K1"]);
                    investorContact.Contact.Designation = collection[(index + 1).ToString() + "_" + "Designation"];
                    investorContact.Contact.EntityID = Authentication.CurrentEntity.EntityID;

                    // Attempt to create new investor contact address.
                    contactAddress = new ContactAddress();
                    contactAddress.CreatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.CreatedDate = DateTime.Now;
                    contactAddress.EntityID = Authentication.CurrentEntity.EntityID;
                    contactAddress.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.LastUpdatedDate = DateTime.Now;

                    contactAddress.Address = new Address();
                    contactAddress.Address.Address1 = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactAddress1"]);
                    contactAddress.Address.Address2 = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactAddress2"]);
                    contactAddress.Address.AddressTypeID = (int)DeepBlue.Models.Admin.Enums.AddressType.Work;
                    contactAddress.Address.City = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactCity"]);
                    contactAddress.Address.Country = Convert.ToInt32(collection[(index + 1).ToString() + "_" + "ContactCountry"]);
                    contactAddress.Address.CreatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.Address.CreatedDate = DateTime.Now;
                    contactAddress.Address.EntityID = Authentication.CurrentEntity.EntityID;
                    contactAddress.Address.LastUpdatedBy = Authentication.CurrentUser.UserID;
                    contactAddress.Address.LastUpdatedDate = DateTime.Now;
                    contactAddress.Address.PostalCode = collection[(index + 1).ToString() + "_" + "ContactZip"];
                    contactAddress.Address.State = Convert.ToInt32(collection[(index + 1).ToString() + "_" + "ContactState"]);

                    /* Add Investor Contact Communication Values */
                    string contactPhoneNo = collection[(index + 1).ToString() + "_" + "ContactPhoneNumber"];
                    string contactFaxNo = collection[(index + 1).ToString() + "_" + "ContactFaxNumber"];
                    string contactEmail = collection[(index + 1).ToString() + "_" + "ContactEmail"];
                    string contactWebAddress = collection[(index + 1).ToString() + "_" + "ContactWebAddress"];

                    if (string.IsNullOrEmpty(contactAddress.Address.Address1) == false
                       || string.IsNullOrEmpty(contactAddress.Address.Address2) == false
                       || string.IsNullOrEmpty(contactAddress.Address.City) == false
                        || string.IsNullOrEmpty(contactAddress.Address.PostalCode) == false
                        || string.IsNullOrEmpty(investorContact.Contact.ContactName) == false
                        || string.IsNullOrEmpty(contactPhoneNo) == false
                        || string.IsNullOrEmpty(contactFaxNo) == false
                        || string.IsNullOrEmpty(contactEmail) == false
                        || string.IsNullOrEmpty(contactWebAddress) == false
                     ) {
                        errorInfo = ValidationHelper.Validate(contactAddress.Address);
                        errorInfo = errorInfo.Union(ValidationHelper.Validate(investorContact.Contact));

                        errorTitle = "<b>Contact Information {0}:</b>\n{1}\n";
                        errors = new StringBuilder();
                        if (errorInfo.Any()) {
                            errors.Append(ValidationHelper.GetErrorInfo(errorInfo));
                        }
                        if (emailValidation.IsValid(contactEmail) == false)
                            errors.Append("Invalid Email\n");
                        if (webAttribute.IsValid(contactWebAddress) == false)
                            errors.Append("Invalid Web Address\n");
                        if (zipAttribute.IsValid(contactAddress.Address.PostalCode) == false)
                            errors.Append("Invalid Zip\n");

                        if (string.IsNullOrEmpty(errors.ToString()) == false) {
                            resultModel.Result += string.Format(errorTitle, count.ToString(), errors.ToString());
                        }

                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investorContact.Contact.ContactAddresses.Add(contactAddress);
                        }
                        if (string.IsNullOrEmpty(resultModel.Result)) {
                            investor.InvestorContacts.Add(investorContact);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.HomePhone, contactPhoneNo);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Fax, contactFaxNo);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.Email, contactEmail);
                            AddCommunication(investorContact.Contact, Models.Admin.Enums.CommunicationType.WebAddress, contactWebAddress);
                        }
                    }

                }
                if (string.IsNullOrEmpty(resultModel.Result)) {
                    errorInfo = InvestorRepository.SaveInvestor(investor);
                    if (errorInfo != null) {
                        resultModel.Result = ValidationHelper.GetErrorInfo(errorInfo);
                    }
                    else {
                        resultModel.Result += SaveCustomValues(collection, investor.InvestorID);
                    }
                }
                if (string.IsNullOrEmpty(resultModel.Result)) {
                    resultModel.Result = "True||" + investor.InvestorID;
                }
            }
            if (ModelState.IsValid == false) {
                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);
        }
コード例 #3
0
ファイル: Investor.cs プロジェクト: jsingh/DeepBlue
        public static NameValueCollection ImportInvestors(CookieCollection cookies)
        {
            NameValueCollection values = new NameValueCollection();
            ImportErrors = new List<KeyValuePair<Models.Entity.Investor, Exception>>();
            TotalImportRecords = 0;
            RecordsImportedSuccessfully = 0;
            List<DeepBlue.Models.Entity.Investor> dbInvestors = ConvertBlueToDeepBlue();
            LogErrors(Errors);
            foreach (DeepBlue.Models.Entity.Investor investor in dbInvestors) {
                // make sure that the investor doesnt already exist
                List<Models.Entity.Investor> existingInvestors = GetInvestors(cookies, null, investor.InvestorName);
                if (existingInvestors.Count > 0) {
                    //make sure the name match exactly
                    Models.Entity.Investor inv = existingInvestors.Where(x => x.InvestorName.Equals(investor.InvestorName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (inv != null) {
                        // investor already exists
                        Util.WriteWarning(string.Format("Investor: {0} already exists. Found investor: Investor Name: {1}, InvestorID: {2}", investor.InvestorName, inv.InvestorName, inv.InvestorID));
                        continue;
                    }
                }

                NameValueCollection formValues = new NameValueCollection();
                TotalImportRecords++;
                try {
                    CreateModel model = new CreateModel();
                    model.Alias = investor.Alias;
                    model.DomesticForeign = investor.IsDomestic;
                    model.EntityType = investor.InvestorEntityTypeID;
                    model.InvestorName = investor.InvestorName;
                    model.Alias = investor.FirstName;
                    model.StateOfResidency = investor.ResidencyState.Value;
                    model.SocialSecurityTaxId = investor.Social;
                    model.Notes = investor.Notes;

                    #region Investor's Address
                    InvestorAddress investorAddress = investor.InvestorAddresses.First();
                    Address address = investorAddress.Address;
                    model.Address1 = address.Address1 ?? "";
                    model.Address2 = address.Address2 ?? "";
                    model.City = address.City ?? "";
                    model.Country = address.Country;
                    model.Zip = address.PostalCode;
                    model.State = address.State.Value;
                    #endregion

                    #region Investor's communication (email, fax etc)
                    List<InvestorCommunication> investorComms = investor.InvestorCommunications.ToList();
                    foreach (InvestorCommunication comm in investorComms) {
                        if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.HomePhone) {
                            model.Phone = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Email) {
                            model.Email = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.WebAddress) {
                            model.WebAddress = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Fax) {
                            model.Fax = comm.Communication.CommunicationValue;
                        }
                    }
                    #endregion

                    #region Investor's Accounts
                    int counter = 0;
                    foreach (InvestorAccount investorAccount in investor.InvestorAccounts.ToList()) {
                        // if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "BankIndex"]) <= 0) continue;
                        formValues.Add(++counter + "_BankIndex", counter.ToString());

                        // Only the following form keys have name different from the object properties
                        //investorAccount.Routing = DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ABANumber"]);
                        //investorAccount.FFCNumber = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFCNO"]);
                        //investorAccount.Account = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountNumber"]);
                        if (investorAccount.Routing != null) {
                            formValues.Add(counter + "_ABANumber", investorAccount.Routing.ToString());
                        }
                        if (!string.IsNullOrEmpty(investorAccount.FFCNumber)) {
                            formValues.Add(counter + "_FFCNO", investorAccount.FFCNumber.ToString());
                        }
                        if (!string.IsNullOrEmpty(investorAccount.Account)) {
                            formValues.Add(counter + "_AccountNumber", investorAccount.Account.ToString());
                        }
                        formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(investorAccount, counter + "_", string.Empty));
                    }
                    model.AccountLength = counter;
                    #endregion

                    #region Investor's contact
                    counter = 0;
                    foreach (InvestorContact investorContact in investor.InvestorContacts) {
                        counter++;
                        //if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ContactIndex"]) <= 0) continue;
                        formValues.Add(counter + "_ContactIndex", counter.ToString());
                        Contact contact = investorContact.Contact;
                        // Only the following form keys have name different from the object properties
                        //investorContact.Contact.ContactName = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactPerson"]);
                        //investorContact.Contact.ReceivesDistributionNotices = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "DistributionNotices"]);
                        //investorContact.Contact.ReceivesFinancials = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "Financials"]);
                        //investorContact.Contact.ReceivesInvestorLetters = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "InvestorLetters"]);
                        //investorContact.Contact.ReceivesK1 = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "K1"]);
                        if (!string.IsNullOrEmpty(contact.ContactName)) {
                            formValues.Add(counter + "_ContactPerson", contact.ContactName);
                        }
                        formValues.Add(counter + "_DistributionNotices", contact.ReceivesDistributionNotices.ToString());
                        formValues.Add(counter + "_Financials", contact.ReceivesFinancials.ToString());
                        formValues.Add(counter + "_InvestorLetters", contact.ReceivesInvestorLetters.ToString());
                        formValues.Add(counter + "_K1", contact.ReceivesK1.ToString());
                        formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(contact, counter + "_", string.Empty));

                        #region Contact's address
                        foreach (ContactAddress contactAddress in contact.ContactAddresses) {
                            Address addr = contactAddress.Address;
                            // Only the following form keys have name different from the object properties
                            // contactAddress.Address.PostalCode = collection[(index + 1).ToString() + "_" + "ContactZip"];
                            if (!string.IsNullOrEmpty(addr.PostalCode)) {
                                formValues.Add(counter + "_ContactZip", addr.PostalCode);
                            }
                            formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(addr, counter + "_Contact", string.Empty));
                        }
                        #endregion

                        #region Contact's communication (email, fax etc)
                        foreach (ContactCommunication comm in contact.ContactCommunications) {
                            string commValue = comm.Communication.CommunicationValue;
                            if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.HomePhone) {
                                formValues.Add(counter + "_ContactPhoneNumber", commValue);
                            } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Email) {
                                formValues.Add(counter + "_ContactEmail", commValue);
                            } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.WebAddress) {
                                formValues.Add(counter + "_ContactWebAddress", commValue);
                            } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Fax) {
                                formValues.Add(counter + "_ContactFaxNumber", commValue);
                            }
                        }
                        #endregion
                    }
                    model.ContactLength = counter;
                    #endregion

                    formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty));

                    // Send the request
                    string url = HttpWebRequestUtil.GetUrl("Investor/Create");
                    byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues));
                    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)) {
                                string resp = readStream.ReadToEnd();
                                if (!string.IsNullOrEmpty(resp)) {
                                    int? investorId = HttpWebRequestUtil.GetNewKeyFromResponse(resp);
                                    if (investorId.HasValue) {
                                        RecordsImportedSuccessfully++;
                                        values = values.Combine(formValues);
                                        Util.WriteNewEntry(string.Format("Created new investor: {0}, InvestorId: {1}", model.InvestorName, investorId));
                                    } else {
                                        ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Investor, Exception>(investor, new Exception(resp)));
                                    }
                                } else {
                                    ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Investor, Exception>(investor, new Exception(resp)));
                                }
                                response.Close();
                                readStream.Close();
                            }
                        }

                    }
                } catch (Exception ex) {
                    ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Investor, Exception>(investor, ex));
                }

            }
            LogErrors(ImportErrors);
            return values;
        }
コード例 #4
0
ファイル: Investor.cs プロジェクト: jsingh/DeepBlue
        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;
        }
コード例 #5
0
ファイル: Investor.cs プロジェクト: jsingh/DeepBlue
 public static void Create(CreateModel model, CookieCollection cookies)
 {
     // Investor.js
     // function name "save"
     // /Investor/Create
     string url = HttpWebRequestUtil.GetUrl("Investor/Create");
     byte[] postData = HttpWebRequestUtil.GetPostData(model, string.Empty, string.Empty);
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies);
 }