public ActionResult AddCommunication(string pid)
        {
            // Send in a new'd up address model with only the pid set.
            CommunicationModel communicationModel = new CommunicationModel();
            communicationModel.PersonID = pid;

            return View("AddCommunication", communicationModel);
        }
        public ActionResult CommitEditCommunication()
        {
            CommunicationModel cModel = new CommunicationModel();
            cModel.CommunicationID = Request.Form["CommunicationID"].ToString();
            cModel.CommunicationURI = Request.Form["CommunicationURI"].ToString();
            cModel.PersonID = Request.Form["PersonID"].ToString();
            cModel.PersonURI = Request.Form["PersonURI"].ToString();
            cModel.HouseholdID = Request.Form["HouseholdID"].ToString();
            cModel.HouseholdURI = Request.Form["HouseholdURI"].ToString();
            cModel.CommunicationTypeID = Request.Form["CommunicationTypeID"].ToString();
            cModel.CommunicationTypeURI = Request.Form["CommunicationTypeURI"].ToString();
            cModel.CommunicationType = Request.Form["CommunicationType"].ToString();
            cModel.CommunicationGeneralType = Request.Form["CommunicationGeneralType"].ToString();
            cModel.SearchCommunicationValue = Request.Form["SearchCommunicationValue"].ToString();
            cModel.CommunicationValue = Request.Form["CommunicationValue"].ToString();
            cModel.Listed = Request.Form["Listed"].ToString().ToLower();
            cModel.CommunicationComment = Request.Form["CommunicationComment"].ToString();
            cModel.CreatedDate = Request.Form["CreatedDate"].ToString();
            cModel.LastUpdatedDate = Request.Form["LastUpdatedDate"].ToString();

            // Update communication for current person.
            string responseResult = Http.HttpPut("https://demo.fellowshiponeapi.com/v1/People/" + cModel.PersonID +"/Communications/"
                + cModel.CommunicationID + "?mode=demo", CommunicationModel.EntityTemplate(cModel));

            return CommunicationSummary(cModel.PersonID, cModel.CommunicationID);
        }
        public ActionResult CommitNewCommunication()
        {
            CommunicationModel cModel = new CommunicationModel();
            cModel.PersonID = Request.Form["PersonID"].ToString();
            cModel.CommunicationTypeID = Request.Form["CommunicationTypeID"].ToString();
            cModel.CommunicationType = Request.Form["CommunicationType"].ToString();
            cModel.CommunicationGeneralType = Request.Form["CommunicationGeneralType"].ToString();
            cModel.CommunicationValue = Request.Form["CommunicationValue"].ToString();
            cModel.SearchCommunicationValue = Request.Form["SearchCommunicationValue"].ToString();
            cModel.Listed = Request.Form["Listed"].ToString().ToLower();
            cModel.CommunicationComment = Request.Form["CommunicationComment"].ToString();

            // Create communication for current person.
            // ISSUE: CommunicationType id is required. Not sure exactly what it is used for.
            // Maybe I can always pass it 1.. But I will just let it be user input for now.

            string responseResult = Http.HttpPost("https://demo.fellowshiponeapi.com/v1/People/"
                + cModel.PersonID + "/Communications?mode=demo", CommunicationModel.EntityTemplate(cModel));

            return PersonCommunications(cModel.PersonID);
        }
Пример #4
0
        public void AddCommunication(CommunicationModel communicationModel)
        {
            if (Communications == null)
                Communications = new List<CommunicationModel>();

            Communications.Add(communicationModel);
        }
Пример #5
0
        public static string EntityTemplate(CommunicationModel cModel)
        {
            const string entityTemplate = @"<?xml version='1.0' encoding='utf-8'?>
                                            <communication id='{0}' uri='{1}'>
                                              <household id='{2}' uri='{3}' />
                                              <person id='{4}' uri='{5}' />
                                              <communicationType id='{6}' uri='{7}'>
                                                <name>{8}</name>
                                              </communicationType>
                                              <communicationGeneralType>{9}</communicationGeneralType>
                                              <communicationValue>{10}</communicationValue>
                                              <searchCommunicationValue>{11}</searchCommunicationValue>
                                              <listed>{12}</listed>
                                              <communicationComment>{13}</communicationComment>
                                              <createdDate>{14}</createdDate>
                                              <lastUpdatedDate>{15}</lastUpdatedDate>
                                            </communication>";

            return String.Format(entityTemplate, cModel.CommunicationID ?? "", cModel.CommunicationURI ?? "", cModel.HouseholdID ?? "", cModel.HouseholdURI ?? "",
                cModel.PersonID ?? "", cModel.PersonURI ?? "", cModel.CommunicationTypeID ?? "", cModel.CommunicationTypeURI ?? "", cModel.CommunicationType ?? "",
                cModel.CommunicationGeneralType ?? "", cModel.CommunicationValue ?? "", cModel.SearchCommunicationValue ?? "", cModel.Listed ?? "",
                cModel.CommunicationComment ?? "", cModel.CreatedDate ?? "", cModel.LastUpdatedDate ?? "");
        }
Пример #6
0
        public static CommunicationModel Convert(RemoteObjects.Communications.communication communication)
        {
            // RULE: For string type NO nulls empty string instead.

            if (communication == null)
                throw new ArgumentNullException("Cannot convert a Null communication to a CommunicationModel.");

            CommunicationModel communicationModel = new CommunicationModel();

            communicationModel.CommunicationID = communication.id ?? "";
            communicationModel.PersonID = communication.person.id ?? "";
            communicationModel.HouseholdID = communication.household.id ?? "";

            communicationModel.CommunicationURI = communication.uri ?? "";
            communicationModel.PersonURI = communication.person.uri ?? "";
            communicationModel.HouseholdURI = communication.household.uri ?? "";

            communicationModel.CommunicationTypeID = "";
            if (communication.communicationType != null && communication.communicationType.id != null)
                communicationModel.CommunicationTypeID = communication.communicationType.id;

            // Nasty work around to a weird XSD object creation issue.
            communicationModel.CommunicationType = "";
            XmlNode[] communicationTypeNodes = null;

            if (communication.communicationType != null && communication.communicationType.name != null)
            {
                communicationTypeNodes = communication.communicationType.name as XmlNode[];
                if (communicationTypeNodes != null && communicationTypeNodes.Length > 0)
                    communicationModel.CommunicationType = communicationTypeNodes[0].Value ?? "";
            }

            communicationModel.CommunicationTypeURI = "";
            if (communication.communicationType != null && communication.communicationType.uri != null)
                communicationModel.CommunicationTypeURI = communication.communicationType.uri;

            communicationModel.CommunicationGeneralType = communication.communicationGeneralType.ToString() ?? "";

            communicationModel.CommunicationValue = communication.communicationValue ?? "";
            communicationModel.SearchCommunicationValue = communication.searchCommunicationValue ?? "";

            communicationModel.Listed = communication.listed.ToString();
            communicationModel.CommunicationComment = communication.communicationComment ?? "";

            communicationModel.CreatedDate = communication.createdDate ?? "";
            communicationModel.LastUpdatedDate = communication.lastUpdatedDate ?? "";

            return communicationModel;
        }