Пример #1
0
        public void AddAddress(AddressModel addressModel)
        {
            if (Addresses == null)
                Addresses = new List<AddressModel>();

            Addresses.Add(addressModel);
        }
        public ActionResult AddAddress(string pid)
        {
            // Send in a new'd up address model with only the pid set.
            AddressModel addressModel = new AddressModel();
            addressModel.PersonID = pid;

            return View("AddAddress", addressModel);
        }
        public ActionResult CommitEditAddress()
        {
            AddressModel aModel = new AddressModel();
            aModel.AddressID = Request.Form["AddressID"].ToString();
            aModel.AddressURI = Request.Form["AddressURI"].ToString();
            aModel.PersonID = Request.Form["PersonID"].ToString();
            aModel.PersonURI = Request.Form["PersonURI"].ToString();
            aModel.HouseholdID = Request.Form["HouseholdID"].ToString();
            aModel.HouseholdURI = Request.Form["HouseholdURI"].ToString();
            aModel.AddressTypeID = Request.Form["AddressTypeID"].ToString();
            aModel.AddressTypeURI = Request.Form["AddressTypeURI"].ToString();
            aModel.AddressType = Request.Form["AddressType"].ToString();
            aModel.Address1 = Request.Form["Address1"].ToString();
            aModel.Address2 = Request.Form["Address2"].ToString();
            aModel.Address3 = Request.Form["Address3"].ToString();
            aModel.City = Request.Form["City"].ToString();
            aModel.PostalCode = Request.Form["PostalCode"].ToString();
            aModel.County = Request.Form["County"].ToString();
            aModel.Country = Request.Form["Country"].ToString();
            aModel.StateProvince = Request.Form["StateProvince"].ToString();
            aModel.CarrierRoute = Request.Form["CarrierRoute"].ToString();
            aModel.DeliveryPoint = Request.Form["DeliveryPoint"].ToString();
            aModel.AddressComment = Request.Form["AddressComment"].ToString();
            aModel.UspsVerified = Request.Form["UspsVerified"].ToString();
            aModel.AddressDate = Request.Form["AddressDate"].ToString();
            aModel.AddressVerifiedDate = Request.Form["AddressVerifiedDate"].ToString();
            aModel.LastVerificationAttemptDate = Request.Form["LastVerificationAttemptDate"].ToString();
            aModel.CreatedDate = Request.Form["CreatedDate"].ToString();
            aModel.LastUpdatedDate = Request.Form["LastUpdatedDate"].ToString();

            // Update address for current person.
            string responseResult = Http.HttpPut("https://demo.fellowshiponeapi.com/v1/People/" + aModel.PersonID
                + "/Addresses/"+ aModel.AddressID +"?mode=demo", AddressModel.EntityTemplate(aModel));

            return AddressSummary(aModel.PersonID, aModel.AddressID);
        }
        public ActionResult CommitNewAddress()
        {
            AddressModel aModel = new AddressModel();
            aModel.PersonID = Request.Form["PersonID"].ToString();
            aModel.AddressTypeID = Request.Form["AddressTypeID"].ToString();
            aModel.AddressType = Request.Form["AddressType"].ToString();
            aModel.Address1 = Request.Form["Address1"].ToString();
            aModel.Address2 = Request.Form["Address2"].ToString();
            aModel.Address3 = Request.Form["Address3"].ToString();
            aModel.City = Request.Form["City"].ToString();
            aModel.PostalCode = Request.Form["PostalCode"].ToString();
            aModel.County = Request.Form["County"].ToString();
            aModel.Country = Request.Form["Country"].ToString();
            aModel.StateProvince = Request.Form["StateProvince"].ToString();
            aModel.CarrierRoute = Request.Form["CarrierRoute"].ToString();
            aModel.DeliveryPoint = Request.Form["DeliveryPoint"].ToString();
            aModel.AddressComment = Request.Form["AddressComment"].ToString();
            aModel.UspsVerified = Request.Form["UspsVerified"].ToString();

            // Create address for current person.
            // ISSUE: AddressType 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/"
                + aModel.PersonID + "/Addresses?mode=demo", AddressModel.EntityTemplate(aModel));

            return PersonAddresses(aModel.PersonID);
        }
Пример #5
0
        public static string EntityTemplate(AddressModel aModel)
        {
            const string entityTemplate = @"<?xml version='1.0' encoding='utf-8'?>
                                            <address id='{0}' uri='{1}'>
                                              <household id='{2}' uri='{3}' />
                                              <person id='{4}' uri='{5}' />
                                              <addressType id='{6}' uri='{7}'>
                                                <name>{8}</name>
                                              </addressType>
                                              <address1>{9}</address1>
                                              <address2>{10}</address2>
                                              <address3>{11}</address3>
                                              <city>{12}</city>
                                              <postalCode>{13}</postalCode>
                                              <county>{14}</county>
                                              <country>{15}</country>
                                              <stProvince>{16}</stProvince>
                                              <carrierRoute>{17}</carrierRoute>
                                              <deliveryPoint>{18}</deliveryPoint>
                                              <addressDate>{19}</addressDate>
                                              <addressComment>{20}</addressComment>
                                              <uspsVerified>{21}</uspsVerified>
                                              <addressVerifiedDate>{22}</addressVerifiedDate>
                                              <lastVerificationAttemptDate>{23}</lastVerificationAttemptDate>
                                              <createdDate>{24}</createdDate>
                                              <lastUpdatedDate>{25}</lastUpdatedDate>
                                            </address>";

            return String.Format(entityTemplate, aModel.AddressID ?? "", aModel.AddressURI ?? "", aModel.HouseholdID ?? "", aModel.HouseholdURI ?? "",
                aModel.PersonID ?? "", aModel.PersonURI ?? "", aModel.AddressTypeID ?? "", aModel.AddressTypeURI ?? "", aModel.AddressType ?? "",
                aModel.Address1 ?? "", aModel.Address2 ?? "", aModel.Address3 ?? "", aModel.City ?? "", aModel.PostalCode ?? "", aModel.County ?? "",
                aModel.Country ?? "", aModel.StateProvince ?? "", aModel.CarrierRoute ?? "", aModel.DeliveryPoint ?? "", aModel.AddressDate ?? "",
                aModel.AddressComment ?? "", aModel.UspsVerified ?? "", aModel.AddressVerifiedDate ?? "", aModel.LastVerificationAttemptDate ?? "",
                aModel.CreatedDate ?? "", aModel.LastUpdatedDate ?? "");
        }
Пример #6
0
        public static AddressModel Convert(RemoteObjects.Addresses.address address)
        {
            // RULE: For string type NO nulls empty string instead.

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

            AddressModel addressModel = new AddressModel();

            addressModel.AddressID = address.id ?? "";
            addressModel.AddressURI = address.uri ?? "";
            addressModel.PersonID = address.person.id ?? "";
            addressModel.PersonURI = address.person.uri ?? "";
            addressModel.HouseholdID = address.household.id ?? "";
            addressModel.HouseholdURI = address.household.uri ?? "";

            addressModel.AddressTypeID = address.addressType.id ?? "";
            addressModel.AddressTypeURI = address.addressType.uri ?? "";
            // Nasty work around to a weird XSD object creation issue.
            addressModel.AddressType = "";
            XmlNode[] addressTypeNodes = null;

            if (address.addressType != null && address.addressType.name != null)
            {
                addressTypeNodes = address.addressType.name as XmlNode[];
                if (addressTypeNodes != null && addressTypeNodes.Length > 0)
                    addressModel.AddressType = addressTypeNodes[0].Value ?? "";
            }

            addressModel.Address1 = address.address1 ?? "";
            addressModel.Address2 = address.address2 ?? "";
            addressModel.Address3 = address.address3 ?? "";
            addressModel.City = address.city ?? "";
            addressModel.PostalCode = address.postalCode ?? "";
            addressModel.County = address.county ?? "";
            addressModel.Country = address.country ?? "";
            addressModel.StateProvince = address.stProvince ?? "";
            addressModel.CarrierRoute = address.carrierRoute ?? "";
            addressModel.DeliveryPoint = address.deliveryPoint ?? "";
            addressModel.AddressDate = address.addressDate ?? "";
            addressModel.AddressComment = address.addressComment ?? "";
            addressModel.UspsVerified = address.uspsVerified ?? "";

            addressModel.AddressVerifiedDate = address.addressVerifiedDate ?? "";
            addressModel.LastVerificationAttemptDate = address.lastVerificationAttemptDate ?? "";
            addressModel.CreatedDate = address.createdDate ?? "";
            addressModel.LastUpdatedDate = address.lastUpdatedDate ?? "";

            return addressModel;
        }