public void B130_GetPostCodes_MockedAgent() { var v = new PostalInfo { CountrySid = "US", City = "Redmond", State = "WA", Places = new PlaceInfoCollection { new PlaceInfo { Name = "Redmond", PostCode = "98052" }, new PlaceInfo { Name = "Redmond", PostCode = "98053" }, new PlaceInfo { Name = "Redmond", PostCode = "98073" } } }; // Example of direct mocking... var mock = new Mock <IZippoAgent>(); mock.Setup(x => x.SendMappedResponseAsync <PostalInfo, Business.Data.Model.PostalInfo>(It.Is <HttpSendArgs>(x => x.HttpMethod == HttpMethod.Get && x.UrlSuffix == "US/WA/Redmond"))).ReturnsHttpAgentResultAsync(v); using var agentTester = Beef.Test.NUnit.AgentTester.CreateWaf <Startup>(sc => sc.ReplaceScoped(mock.Object)); agentTester.Test <PostalInfoAgent, PostalInfo>() .ExpectStatusCode(HttpStatusCode.OK) .ExpectValue(_ => v) .Run(a => a.GetPostCodesAsync("US", "WA", "Redmond")); }
public ContactChange(Contact contact) { this.Email = contact.Email; this.Voice = contact.Voice; this.Fax = contact.Fax; this.PostalInfo = contact.PostalInfo; }
public ContactChange(Contact contact) { this.Email = contact.Email; this.Voice = contact.Voice; this.Fax = contact.Fax; this.PostalInfo = contact.PostalInfo; this.DiscloseFlag = contact.DiscloseFlag; this.DiscloseMask = contact.DiscloseMask; }
public Task <PostalInfo> UpdatePostCodesAsync(PostalInfo value, RefDataNamespace.Country?country, string?state, string?city) => ManagerInvoker.Current.InvokeAsync(this, async() => { await value.Validate().Mandatory().RunAsync(throwOnError: true).ConfigureAwait(false); Cleaner.CleanUp(value, country, state, city); await MultiValidator.Create() .Add(country.Validate(nameof(country)).Mandatory().IsValid()) .Add(state.Validate(nameof(state)).Mandatory()) .Add(city.Validate(nameof(city)).Mandatory()) .RunAsync(throwOnError: true).ConfigureAwait(false); return(Cleaner.Clean(await _dataService.UpdatePostCodesAsync(value, country, state, city).ConfigureAwait(false))); }, BusinessInvokerArgs.Update);
/// <summary> /// Extracts data from XML element /// </summary> /// <param name="objectElement">Object XML element</param> public void Extract(XElement objectElement) { this.Id = objectElement.Element(SchemaHelper.ContactNs.GetName("id")).Value; this.Roid = objectElement.Element(SchemaHelper.ContactNs.GetName("roid")).Value; this.Status = objectElement .Elements(SchemaHelper.ContactNs.GetName("status")) .Select(status => StatusInfo.Extract(status)) .ToList(); this.PostalInfos = objectElement.Elements(SchemaHelper.ContactNs.GetName("postalInfo")) .Select(pos => PostalInfo.Extract(pos)) .ToList(); this.Voice = objectElement .Elements(SchemaHelper.ContactNs.GetName("voice")) .Select(voice => VoiceInfo.Extract(voice)) .FirstOrDefault(); this.Fax = objectElement .Elements(SchemaHelper.ContactNs.GetName("fax")) .Select(fax => fax.Value) .FirstOrDefault(); var email = objectElement.Element(SchemaHelper.ContactNs.GetName("email")); this.Email = email == null ? null : email.Value; var clientId = objectElement.Element(SchemaHelper.ContactNs.GetName("clID")); this.ClientId = clientId == null ? null : clientId.Value; var creadteId = objectElement.Element(SchemaHelper.ContactNs.GetName("crID")); this.CreateId = creadteId == null ? null : creadteId.Value; var createDate = objectElement.Element(SchemaHelper.ContactNs.GetName("crDate")); this.CreateDate = createDate == null ? (DateTime?)null : DateTime.Parse(createDate.Value).ToUniversalTime(); var updateIdElement = objectElement.Element(SchemaHelper.ContactNs.GetName("upID")); this.UpdateId = updateIdElement == null ? null : updateIdElement.Value; var updateDateElement = objectElement.Element(SchemaHelper.ContactNs.GetName("upDate")); this.UpdateDate = updateDateElement == null ? (DateTime?)null : DateTime.Parse(updateDateElement.Value).ToUniversalTime(); var transferDateElement = objectElement.Element(SchemaHelper.ContactNs.GetName("trDate")); this.TransferDate = transferDateElement == null ? (DateTime?)null : DateTime.Parse(transferDateElement.Value).ToUniversalTime(); this.Auth = objectElement .Elements(SchemaHelper.ContactNs.GetName("authInfo")) .Select(authInfo => AuthInfo.Extract(authInfo)) .FirstOrDefault(); this.Disclose = objectElement .Elements(SchemaHelper.ContactNs.GetName("disclose")) .Select(dis => { bool discloseFlag; if (!Boolean.TryParse(dis.Attribute("flag").Value, out discloseFlag)) { discloseFlag = Int32.Parse(dis.Attribute("flag").Value) != 0; } var disclose = new Disclose(discloseFlag); if (dis.Elements() != null) { var elements = new List <string>(); foreach (var element in dis.Elements()) { elements.Add(element.Name.LocalName); } disclose.DisclosingFields = elements; } return(disclose); }) .FirstOrDefault(); }
protected XmlElement AddressToXml(XmlDocument doc, string tagName, PostalInfo nameAddress) { XmlElement name_address_element = null; if (nameAddress != null) { name_address_element = doc.CreateElement(tagName, Namespace); if (nameAddress.m_type == null) { throw new EppException("missing the address type (postal info)"); } name_address_element.SetAttribute("type", nameAddress.m_type); if (nameAddress.m_name != null) { AddXmlElement(doc, name_address_element, "contact:name", nameAddress.m_name, ContactNamespace); } if (nameAddress.m_org != null) { AddXmlElement(doc, name_address_element, "contact:org", nameAddress.m_org, ContactNamespace); } if (nameAddress.m_address != null) { PostalAddress address = nameAddress.m_address; XmlElement address_element = doc.CreateElement("contact:addr", ContactNamespace); // Because this method is used by contact create and update, // the lowest common denominator (update), says that all // members are optional. if (address.Street1 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street1, ContactNamespace); } if (address.Street2 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street2, ContactNamespace); } if (address.Street3 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street3, ContactNamespace); } if (address.City != null) { AddXmlElement(doc, address_element, "contact:city", address.City, ContactNamespace); } if (address.StateProvince != null) { AddXmlElement(doc, address_element, "contact:sp", address.StateProvince, ContactNamespace); } if (address.PostalCode != null) { AddXmlElement(doc, address_element, "contact:pc", address.PostalCode, ContactNamespace); } if (address.CountryCode != null) { AddXmlElement(doc, address_element, "contact:cc", address.CountryCode, ContactNamespace); } if (address_element.ChildNodes.Count > 0) { name_address_element.AppendChild(address_element); } } } return(name_address_element); }
public Task <PostalInfo> UpdatePostCodesAsync(PostalInfo value, RefDataNamespace.Country?country, string?state, string?city) => DataSvcInvoker.Current.InvokeAsync(this, async() => { var __result = await _data.UpdatePostCodesAsync(Check.NotNull(value, nameof(value)), country, state, city).ConfigureAwait(false); await _evtPub.PublishValue(__result, new Uri($"/postalinfo/{_evtPub.FormatKey(__result)}", UriKind.Relative), $"Demo.PostalInfo.{_evtPub.FormatKey(__result)}", "Update", country.Code, state, city).SendAsync().ConfigureAwait(false); return(__result); });
public IActionResult UpdatePostCodes([FromBody] PostalInfo value, string?country, string?state, string?city) => new WebApiPut <PostalInfo>(this, value, () => _manager.GetPostCodesAsync(country, state, city), () => _manager.UpdatePostCodesAsync(WebApiActionBase.Value(value), country, state, city), operationType: OperationType.Update, statusCode: HttpStatusCode.OK, alternateStatusCode: null);
public Task <PostalInfo> UpdatePostCodesAsync(PostalInfo value, RefDataNamespace.Country?country, string?state, string?city) => DataInvoker.Current.InvokeAsync(this, async() => { var __dataArgs = HttpSendArgs.Create(_mapper, HttpMethod.Put, $"{country.Code}/{state}/{city}"); return((await _httpAgent.SendMappedRequestResponseAsync <PostalInfo, Model.PostalInfo, PostalInfo, Model.PostalInfo>(__dataArgs, value).ConfigureAwait(false)).Value); });
public Task <WebApiAgentResult <PostalInfo> > UpdatePostCodesAsync(PostalInfo value, string?country, string?state, string?city, WebApiRequestOptions?requestOptions = null) => PutAsync <PostalInfo>("api/v1/postal/{country}/{state}/{city}", Beef.Check.NotNull(value, nameof(value)), requestOptions: requestOptions, args: new WebApiArg[] { new WebApiArg <string?>("country", country), new WebApiArg <string?>("state", state), new WebApiArg <string?>("city", city) });