private bool LoadByPrimaryKeyDynamic(System.Int32 id) { DiscountQuery query = new DiscountQuery(); query.Where(query.Id == id); return(this.Load(query)); }
protected void InitQuery(DiscountQuery query) { query.OnLoadDelegate = this.OnQueryLoaded; if (!query.es2.HasConnection) { query.es2.Connection = ((IEntityCollection)this).Connection; } }
public static List <Discount> GetAll(int storeId) { DiscountQuery q = new DiscountQuery(); q.Where(q.StoreId == storeId); q.OrderBy(q.DnnRoleId.Ascending); DiscountCollection collection = new DiscountCollection(); collection.Load(q); return(collection.ToList()); }
internal static List <Discount> GetActiveDiscountsForCurrentUser(int storeId) { UserInfo userInfo = UserController.GetCurrentUserInfo(); RoleController roleController = new RoleController(); List <RoleInfo> userRoles = roleController.GetUserRoles(userInfo.PortalID, userInfo.UserID).ToList <RoleInfo>(); List <int> roleIds = userRoles.ConvertAll(r => r.RoleID); DiscountQuery q = new DiscountQuery(); q.Where(q.StoreId == storeId); q.Where(q.IsActive == true); if (roleIds.Count > 0) { q.Where(q.Or( q.DnnRoleId.IsNull(), q.DnnRoleId.In(roleIds.ToArray()) )); } else { q.Where(q.Or(q.DnnRoleId.IsNull())); } DateTime now = DateTime.Now; q.Where(q.Or( q.ValidFromDate.IsNull(), now >= q.ValidFromDate )); q.Where(q.Or( q.ValidToDate.IsNull(), now <= q.ValidToDate )); DiscountCollection discounts = new DiscountCollection(); discounts.Load(q); return(discounts.ToList()); }
public bool Load(DiscountQuery query) { this.query = query; InitQuery(this.query); return(Query.Load()); }