Beispiel #1
0
        /// <summary>
        /// Get the existing sync state representing the item with this CRM id, if it exists, else null.
        /// </summary>
        /// <param name="crmItemId">The id of a CRM item</param>
        /// <returns>the existing sync state representing the item with this CRM id, if it exists, else null.</returns>
        protected SyncState <OutlookItemType> GetExistingSyncState(string crmItemId)
        {
            SyncState <OutlookItemType> result;

            try
            {
                /* if there are duplicate entries I want them logged */
                result = ItemsSyncState.SingleOrDefault(a => a.CrmEntryId == crmItemId);
            }
            catch (InvalidOperationException notUnique)
            {
                Log.Error(
                    String.Format(
                        "AppointmentSyncing.AddItemFromOutlookToCrm: CRM Id {0} was not unique in this.ItemsSyncState?",
                        crmItemId),
                    notUnique);

                /* but if it isn't unique, the first will actually do for now */
                result = ItemsSyncState.FirstOrDefault(a => a.CrmEntryId == crmItemId);
            }

            return(result);
        }