コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EMailIssueExternalRecipient"/> class.
 /// </summary>
 /// <param name="row">The row.</param>
 private EMailIssueExternalRecipient(EMailIssueExternalRecipientRow row)
 {
     _srcRow = row;
 }
コード例 #2
0
        public static int Create(int IssueId, string EMail)
        {
            EMailIssueExternalRecipientRow newRow = new EMailIssueExternalRecipientRow();

            newRow.IssueId = IssueId;
            newRow.EMail = EMail;

            newRow.Update();

            return newRow.PrimaryKeyId;
        }
コード例 #3
0
        /// <summary>
        /// Updates the specified recipient.
        /// </summary>
        /// <param name="recipient">The recipient.</param>
        public static void Update(int IssueId, Hashtable recipientHash)
        {
            if(!Incident.CanUpdateExternalRecipients(IssueId))
                throw new AccessDeniedException();

            using(DbTransaction tran = DbTransaction.Begin())
            {
                EMailIssueExternalRecipientRow[] list = EMailIssueExternalRecipientRow.List(IssueId);

                Hashtable alreadyAddedItems = new Hashtable();

                foreach(EMailIssueExternalRecipientRow row in list)
                {
                    if(!alreadyAddedItems.ContainsKey(row.EMail.ToLower()))
                        alreadyAddedItems.Add(row.EMail.ToLower(),null);
                }

                // Delete
                foreach(EMailIssueExternalRecipientRow row in list)
                {
                    if(!recipientHash.ContainsKey(row.EMailIssueExternalRecipientId))
                    {
                        alreadyAddedItems.Remove(row.EMail.ToLower());
                        row.Delete();
                    }
                }

                // Insert
                foreach(int Key in recipientHash.Keys)
                {
                    string Value = (string)recipientHash[Key];

                    if(Key<0 && !alreadyAddedItems.ContainsKey(Value.ToLower()))
                    {
                        EMailIssueExternalRecipientRow newRow = new EMailIssueExternalRecipientRow();
                        newRow.IssueId = IssueId;
                        newRow.EMail = Value;

                        newRow.Update();

                        alreadyAddedItems.Add(Value.ToLower(),null);
                    }
                }

                tran.Commit();
            }
        }