Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- var contactManager = GetContactManager();
- var contact = contactManager.LoadContactReadOnly(contactId);
- if (contact == null)
- {
- Log.Info("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields: Contact not found!", this);
- throw new ContactNotFoundException();
- }
- var customFacet = contact.GetFacet<IContactCompanyInfo>(ContactCompanyInfo.FACET_NAME);
- Log.Info("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields: Company: " + customFacet.Company + " Industry: " + customFacet.Industry + " Sub Industry: " + customFacet.SubIndustry + " Revenue Range: " + customFacet.RevenueRange, this);
- var serializerSettings = new JsonSerializerSettings
- {
- ContractResolver = new XdbJsonContractResolver(client.Model, serializeFacets: true, serializeContactInteractions: true),
- DateTimeZoneHandling = DateTimeZoneHandling.Utc,
- DefaultValueHandling = DefaultValueHandling.Ignore
- };
- return Newtonsoft.Json.Linq.JObject.Parse(JsonConvert.SerializeObject(customFacet, serializerSettings));
- }
- catch (ContactNotFoundException ex)
- {
- Log.Error("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields", ex, this);
- return Request.CreateResponse(HttpStatusCode.NotFound, ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement