public bool CanSend(int account_id) { foreach (ReminderAccountProperty rap in Collection <ReminderAccountProperty> .GetSafeCollection(mInstance.ReminderAccountProperties)) { // find the account property value AccountPropertyValue apv = (AccountPropertyValue)Session.CreateCriteria(typeof(AccountPropertyValue)) .Add(Expression.Eq("Account.Id", account_id)) .Add(Expression.Eq("AccountProperty.Id", rap.AccountProperty.Id)) .SetMaxResults(1) .UniqueResult(); if (apv == null && rap.Unset) { // account doesn't have this property value, but the reminder is set // to include accounts that don't have the property set return(true); } if (apv.Value != rap.Value) { // property value doesn't match return(false); } } return(true); }
public List<TransitAccountPropertyValue> GetAllAccountPropertyValues(string ticket, int accountid, int groupid) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ICriteria c = session.CreateCriteria(typeof(AccountProperty)); if (groupid > 0) c.Add(Expression.Eq("AccountPropertyGroup.Id", groupid)); IList properties = c.List(); List<TransitAccountPropertyValue> result = new List<TransitAccountPropertyValue>(properties.Count); foreach (AccountProperty property in properties) { AccountPropertyValue value = (AccountPropertyValue)session.CreateCriteria(typeof(AccountPropertyValue)) .Add(Expression.Eq("Account.Id", accountid)) .Add(Expression.Eq("AccountProperty.Id", property.Id)) .UniqueResult(); if (value == null) { value = new AccountPropertyValue(); value.AccountProperty = property; value.Value = property.DefaultValue; value.Account = session.Load<Account>(accountid); } ManagedAccountPropertyValue m_instance = new ManagedAccountPropertyValue(session, value); result.Add(m_instance.GetTransitInstance(sec)); } return result; } }