Ejemplo n.º 1
0
        public ActionConfirmation Delete(int itemId)
        {
            var emailToDelete = _queueRepository.Get(itemId);

            if (emailToDelete != null)
            {
                try
                {
                    _queueRepository.Delete(emailToDelete);
                    _queueRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("The email was successfully deleted."));
                }
                catch
                {
                    return
                        (ActionConfirmation.CreateFailure(
                             "A problem was encountered preventing the email from being deleted. " +
                             "Another item likely depends on this email"));
                }
            }

            return
                (ActionConfirmation.CreateFailure(
                     "The email could not be found to deletion. It may already have been deleted"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 单条删除邮件
        /// </summary>
        /// <param name="id">要删除的邮件ID</param>
        public void Delete(int id)
        {
            //若能获取到则删除
            EmailQueueEntry deleteEntry = emailQueueRepository.Get(id);

            if (deleteEntry != null)
            {
                EventBus <EmailQueueEntry> .Instance().OnBefore(deleteEntry, new CommonEventArgs(EventOperationType.Instance().Delete()));

                emailQueueRepository.Delete(deleteEntry);
                EventBus <EmailQueueEntry> .Instance().OnAfter(deleteEntry, new CommonEventArgs(EventOperationType.Instance().Delete()));
            }
        }