Ejemplo n.º 1
0
 private IEnumerable<ErrorInfo> Validate(UnderlyingFundContact underlyingFundContact)
 {
     return ValidationHelper.Validate(underlyingFundContact);
 }
Ejemplo n.º 2
0
        public static int? CreateUnderlyingFundContact(UnderlyingFundContact ufContact, CookieCollection cookies, out string resp)
        {
            resp = string.Empty;
            int? returnUFContactID = null;
            UnderlyingFundContactModel contactModel = new UnderlyingFundContactModel();
            contactModel.UnderlyingFundId = ufContact.UnderlyingtFundID.Value;
            contactModel.ContactName = ufContact.Contact.ContactName;
            contactModel.ContactTitle = ufContact.Contact.Title;
            contactModel.ContactNotes = ufContact.Contact.Notes;
            List<ContactCommunication> contactCommunications = ufContact.Contact.ContactCommunications.ToList();
            foreach (ContactCommunication comm in contactCommunications) {
                if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Email) {
                    contactModel.Email = comm.Communication.CommunicationValue;
                }

                if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.HomePhone) {
                    contactModel.Phone = comm.Communication.CommunicationValue;
                }
            }

            NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(contactModel, string.Empty, string.Empty);
            // Send the request
            string url = HttpWebRequestUtil.GetUrl("Deal/CreateUnderlyingFundContact");
            string data = HttpWebRequestUtil.ToFormValue(formValues);
            messageLog.AppendLine("Deal/CreateUnderlyingFundContact. Form Data: ").AppendLine(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();
                        int retVal = 0;
                        if(Int32.TryParse(resp, out retVal)){
                            returnUFContactID = retVal;
                        }
                        messageLog.AppendLine("Response: " + retVal);
                        response.Close();
                        readStream.Close();
                    }
                }
            }
            return returnUFContactID;
        }