Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. try
  2. {
  3. var contactManager = GetContactManager();
  4. var contact = contactManager.LoadContactReadOnly(contactId);
  5. if (contact == null)
  6. {
  7. Log.Info("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields: Contact not found!", this);
  8. throw new ContactNotFoundException();
  9. }
  10. var customFacet = contact.GetFacet<IContactCompanyInfo>(ContactCompanyInfo.FACET_NAME);
  11. Log.Info("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields: Company: " + customFacet.Company + " Industry: " + customFacet.Industry + " Sub Industry: " + customFacet.SubIndustry + " Revenue Range: " + customFacet.RevenueRange, this);
  12. var serializerSettings = new JsonSerializerSettings
  13. {
  14. ContractResolver = new XdbJsonContractResolver(client.Model, serializeFacets: true, serializeContactInteractions: true),
  15. DateTimeZoneHandling = DateTimeZoneHandling.Utc,
  16. DefaultValueHandling = DefaultValueHandling.Ignore
  17. };
  18. return Newtonsoft.Json.Linq.JObject.Parse(JsonConvert.SerializeObject(customFacet, serializerSettings));
  19. }
  20. catch (ContactNotFoundException ex)
  21. {
  22. Log.Error("MySite.Presentation.Controllers.CustomFieldsController.GetCustomFields", ex, this);
  23. return Request.CreateResponse(HttpStatusCode.NotFound, ex.Message);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement