コード例 #1
0
        /// <summary>
        /// Creates or updates communication.
        /// </summary>
        /// <param name="communicationItem"><see cref="CommunicationItem"/> instance.</param>
        private void CreateOrUpdateCommunication(CommunicationItem communicationItem)
        {
            ActualizePrimaryState(communicationItem.CommunicationTypeId);
            Entity communicationEntity = GetCommunicationEntity();

            communicationEntity.SetColumnValue(DefCommunicationTypeColumnName + "Id", communicationItem.CommunicationTypeId);
            communicationEntity.SetColumnValue(NumberColumnName, communicationItem.ColumnValue);
            communicationEntity.SetColumnValue(PrimaryColumnName, true);
            communicationEntity.Save();
        }
コード例 #2
0
        /// <summary>
        /// Removes communication.
        /// </summary>
        /// <param name="communicationItem"><see cref="CommunicationItem"/> instance to remove.</param>
        /// <remarks>Actualizes primary flag column for all records of <see cref="CommunicationItem.CommunicationTypeId"/> type.</remarks>
        private void RemoveCommunication(CommunicationItem communicationItem)
        {
            ActualizePrimaryState(communicationItem.CommunicationTypeId);
            Entity communicationEntity = CheckExists(communicationItem);

            if (communicationEntity != null)
            {
                communicationEntity.Delete();
            }
        }
コード例 #3
0
        /// <summary>
        /// Checks communication exists.
        /// If communication entity was found, returns it.
        /// </summary>
        /// <param name="communicationItem"><see cref="CommunicationItem"/> instance.</param>
        /// <returns>Communication entity instance.</returns>
        protected virtual Entity CheckExists(CommunicationItem communicationItem)
        {
            var esq = GetDefCommunicationESQ();

            ApplyTypeFilter(esq, communicationItem.CommunicationTypeId);
            if (communicationItem.IsNew)
            {
                ApplyValueFilter(esq, communicationItem.ColumnValue);
            }
            else if (communicationItem.IsChanged || communicationItem.IsDeleted)
            {
                ApplyValueFilter(esq, communicationItem.ColumnOldValue);
            }
            var resultCollection = esq.GetEntityCollection(UserConnection);

            if (resultCollection.Count > 0)
            {
                return(resultCollection.First());
            }
            return(null);
        }