Example #1
0
        public static void CreateEntitySharePointDocumentLocation(this IDynamicsClient _dynamicsClient, string entityName, string entityId, string folderName, string name)
        {
            switch (entityName.ToLower())
            {
            case "account":
                var account = _dynamicsClient.GetAccountById(entityId);
                _dynamicsClient.CreateAccountDocumentLocation(account, folderName, name);
                break;

            case "application":
                var application = _dynamicsClient.GetApplicationByIdWithChildren(entityId).GetAwaiter().GetResult();
                _dynamicsClient.CreateApplicationDocumentLocation(application, folderName, name);
                break;

            case "contact":
                var contact = _dynamicsClient.GetContactById(entityId).GetAwaiter().GetResult();
                _dynamicsClient.CreateContactDocumentLocation(contact, folderName, name);
                break;

            case "worker":
                var worker = _dynamicsClient.GetWorkerByIdWithChildren(entityId).GetAwaiter().GetResult();
                _dynamicsClient.CreateWorkerDocumentLocation(worker, folderName, name);
                break;

            case "event":
                var eventEntity = _dynamicsClient.GetEventByIdWithChildren(entityId);
                _dynamicsClient.CreateEventDocumentLocation(eventEntity, folderName, name);
                break;

            case "licence":
                var licenceEntity = _dynamicsClient.GetLicenceByIdWithChildren(entityId);
                _dynamicsClient.CreateLicenceDocumentLocation(licenceEntity, folderName, name);
                break;
            }
        }