/// <summary> /// Lists the specified issue id. /// </summary> /// <param name="IssueId">The issue id.</param> /// <returns></returns> public static EMailIssueExternalRecipient[] List(int IssueId) { ArrayList retVal = new ArrayList(); foreach (EMailIssueExternalRecipientRow row in EMailIssueExternalRecipientRow.List(IssueId)) { retVal.Add(new EMailIssueExternalRecipient(row)); } return((EMailIssueExternalRecipient[])retVal.ToArray(typeof(EMailIssueExternalRecipient))); }
public static int Create(int IssueId, string EMail) { EMailIssueExternalRecipientRow newRow = new EMailIssueExternalRecipientRow(); newRow.IssueId = IssueId; newRow.EMail = EMail; newRow.Update(); return(newRow.PrimaryKeyId); }
/// <summary> /// Strings the list. /// </summary> /// <param name="IssueId">The issue id.</param> /// <returns></returns> public static string[] StringList(int IssueId) { ArrayList retVal = new ArrayList(); foreach (EMailIssueExternalRecipientRow row in EMailIssueExternalRecipientRow.List(IssueId)) { retVal.Add(row.EMail); } return((string[])retVal.ToArray(typeof(string))); }
/// <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(); } }
/// <summary> /// Initializes a new instance of the <see cref="EMailIssueExternalRecipient"/> class. /// </summary> /// <param name="row">The row.</param> private EMailIssueExternalRecipient(EMailIssueExternalRecipientRow row) { _srcRow = row; }