Esempio n. 1
0
        protected override ContactFolderResponse InternalExecute()
        {
            ExchangeVersion.Current = ExchangeVersion.Latest;
            MailboxSession mailboxIdentityMailboxSession = base.MailboxIdentityMailboxSession;
            IdAndSession   idAndSession = base.IdConverter.ConvertFolderIdToIdAndSession(this.parentFolderId, IdConverter.ConvertOption.IgnoreChangeKey);
            StoreId        id;

            try
            {
                using (Folder folder = ContactsFolder.Create(mailboxIdentityMailboxSession, idAndSession.Id, StoreObjectType.ContactsFolder, this.displayName, CreateMode.CreateNew))
                {
                    PeopleFilterGroupPriorityManager.SetSortGroupPriorityOnFolder(folder, this.priority);
                    folder.Save();
                    folder.Load(new PropertyDefinition[]
                    {
                        FolderSchema.Id
                    });
                    id = folder.Id;
                }
            }
            catch (ObjectExistedException)
            {
                return(new ContactFolderResponse
                {
                    ResponseCode = ResponseCodeType.ErrorFolderExists.ToString()
                });
            }
            PeopleFilterGroupPriorityManager peopleFilterGroupPriorityManager = new PeopleFilterGroupPriorityManager(mailboxIdentityMailboxSession, new XSOFactory());

            mailboxIdentityMailboxSession.ContactFolders.MyContactFolders.Set(peopleFilterGroupPriorityManager.GetMyContactFolderIds());
            ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(id, new MailboxId(mailboxIdentityMailboxSession), null);

            return(new ContactFolderResponse
            {
                ResponseCode = ResponseCodeType.NoError.ToString(),
                FolderId = new FolderId
                {
                    Id = concatenatedId.Id,
                    ChangeKey = concatenatedId.ChangeKey
                }
            });
        }