示例#1
0
        private static void LogToConsole(CreateOrUpdateUserAndContactResponse response)
        {
            System.Console.WriteLine($"User respons: ");
            LogToConsole(response.synchronizeUserOKResponset.Successful ?? false,
                         response.synchronizeUserOKResponset.ErrorMessage,
                         response.synchronizeUserOKResponset.ErrorDetails);

            System.Console.WriteLine($"Contact respons: ");
            LogToConsole(response.synchronizeContactPersonOKResponse.Successful ?? false,
                         response.synchronizeContactPersonOKResponse.ErrorMessage,
                         response.synchronizeContactPersonOKResponse.ErrorDetails);
        }
        public static CreateOrUpdateUserAndContactResponse CreateOrUpdateUserAndContact(ServiceHelper serviceHelper, UserInfo userInfo)
        {
            SynchronizeContactPersonArgsParameter synchronizeContactPersonArgsParameter = new SynchronizeContactPersonArgsParameter()
            {
                ExternalId = userInfo.ExternalId,
                Active     = userInfo.Active,
                FirstName  = userInfo.FirstName,
                LastName   = userInfo.LastName,
                Title      = userInfo.Title,
                Enterprise = userInfo.Enterprise
            };

            SynchronizeContactPersonOKResponse synchronizeContactPersonOKResponse = serviceHelper.SynchronizeContact(synchronizeContactPersonArgsParameter);

            List <SynchronizeUserArgsParameterProfilesItem> profilesItems = new List <SynchronizeUserArgsParameterProfilesItem>();

            if (userInfo.ShoudHaveProfile)
            {
                profilesItems.Add(new SynchronizeUserArgsParameterProfilesItem()
                {
                    EnterpriseId = userInfo.Enterprise,
                    Role         = "4",
                    FromDate     = DateTime.Now,
                });
            }

            SynchronizeUserArgsParameter synchronizeUserArgsParameter = new SynchronizeUserArgsParameter()
            {
                ContactExternalId = userInfo.ExternalId,
                Profiles          = profilesItems,
                Login             = userInfo.Login,
                IsActive          = userInfo.Active
            };

            SynchronizeUserOKResponse synchronizeUserOKResponse = serviceHelper.SynchronizeUser(synchronizeUserArgsParameter);

            CreateOrUpdateUserAndContactResponse createOrUpdateUserAndContactResponse = new CreateOrUpdateUserAndContactResponse()
            {
                synchronizeContactPersonOKResponse = synchronizeContactPersonOKResponse,
                synchronizeUserOKResponset         = synchronizeUserOKResponse
            };

            return(createOrUpdateUserAndContactResponse);
        }