public IHttpActionResult GetListsWithAllAttributes(string orgName, [FromUri]DynamicsCredentials credentials, [FromUri] bool translate = false, [FromUri] bool allAttributes = true) { try { crmService = new CrmService(credentials, orgName); helper = new CrmApiHelper(crmService); var lists = crmService.getAllLists(allAttributes); var goodLookingLists = helper.getValuesFromLists(lists, translate, allAttributes); crmService.logout(); return Ok(goodLookingLists); } catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException) { return Unauthorized(); } catch(NullReferenceException) { return BadRequest(); } }
public IHttpActionResult GetContactsWithAttributes(string orgName, string listId, [FromUri]DynamicsCredentials credentials, [FromUri] int top = 0, [FromUri] bool translate = true, [FromUri] bool allAttributes = true) { try { crmService = new CrmService(credentials, orgName); helper = new CrmApiHelper(crmService); var contacts = crmService.getContactsInList(listId, allAttributes, top); var goodLookingContacts = helper.getValuesFromContacts(contacts, translate, allAttributes); crmService.logout(); return Ok(goodLookingContacts); } catch (Exception ex) when (ex is MessageSecurityException || ex is ArgumentNullException) { return Unauthorized(); } catch (Exception ex) when (ex is NullReferenceException || ex is FormatException) { return BadRequest(); } }