public List <MailAlertData> GetAlerts(int mailboxId = -1, MailAlertTypes type = MailAlertTypes.Empty) { using (var dao = new DaoFactory()) { return(dao.CreateAlertDao(Tenant, User) .GetAlerts(mailboxId, type) .ConvertAll(ToMailAlert)); } }
public List <Alert> GetAlerts(int mailboxId = -1, MailAlertTypes type = MailAlertTypes.Empty) { var query = Query() .Where(AlertsTable.Columns.Tenant, Tenant) .Where(AlertsTable.Columns.User, CurrentUserId); if (mailboxId > 0) { query.Where(AlertsTable.Columns.MailboxId, mailboxId); } if (type != MailAlertTypes.Empty) { query.Where(AlertsTable.Columns.Type, (int)type); } return(Db.ExecuteList(query) .ConvertAll(ToAlert)); }
public bool DeleteAlert(MailAlertTypes type) { using (var daoFactory = new DaoFactory()) { var dao = daoFactory.CreateAlertDao(Tenant, User); var quotaAlerts = dao.GetAlerts(-1, type); if (!quotaAlerts.Any()) { return(true); } var result = dao.DeleteAlerts(quotaAlerts.Select(a => a.Id).ToList()); if (result <= 0) { throw new Exception("Delete old alerts failed"); } } return(true); }