Example #1
0
        /// <summary>
        /// Lists this instance.
        /// </summary>
        /// <returns></returns>
        public static SmtpBox[] List()
        {
            List <SmtpBox> retVal = new List <SmtpBox>();

            foreach (SmtpBoxRow row in SmtpBoxRow.List())
            {
                retVal.Add(new SmtpBox(row));
            }

            return(retVal.ToArray());
        }
Example #2
0
        /// <summary>
        /// Gets the default.
        /// </summary>
        /// <returns></returns>
        public static SmtpBox GetDefault()
        {
            SmtpBoxRow[] rows = SmtpBoxRow.List(FilterElement.EqualElement(SmtpBoxRow.ColumnIsDefault, true));

            // Fix No Default Problem
            if (rows.Length == 0)
            {
                rows = SmtpBoxRow.List();
            }

            if (rows.Length > 0)
            {
                return(new SmtpBox(rows[0]));
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Sets the default.
        /// </summary>
        /// <param name="smtpBoxId">The SMTP box id.</param>
        public static void SetDefault(int smtpBoxId)
        {
            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Reset All Default
                foreach (SmtpBoxRow row in SmtpBoxRow.List(FilterElement.EqualElement(SmtpBoxRow.ColumnIsDefault, true)))
                {
                    row.IsDefault = false;
                    row.Update();
                }

                SmtpBoxRow newDefaultRow = new SmtpBoxRow(smtpBoxId);
                newDefaultRow.IsDefault = true;
                newDefaultRow.Update();

                tran.Commit();
            }
        }
Example #4
0
        /// <summary>
        /// Commits the test email.
        /// </summary>
        /// <param name="checkUid">The check uid.</param>
        /// <returns></returns>
        public static bool CommitTestEmail(Guid checkUid)
        {
            SmtpBoxRow[] rows = SmtpBoxRow.List(FilterElement.EqualElement(SmtpBoxRow.ColumnCheckUid, checkUid));

            if (rows.Length > 0)
            {
                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    foreach (SmtpBoxRow row in rows)
                    {
                        row.Checked = true;
                        row.Update();
                    }

                    tran.Commit();
                }
            }

            return(rows.Length > 0);
        }