public static bool Login(string username, string password)
        {
            int userCount = 0;
            EntityCollection users = new EntityCollection(new UserEntityFactory());
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(PredicateFactory.CompareValue(UserFieldIndex.UserId, ComparisonOperator.Equal, username));
            filter.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(UserFieldIndex.Password, ComparisonOperator.Equal, password));

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                userCount = adapter.GetDbCount(users, filter);
            }

            return (userCount == 1);
        }
        public static List<ProductEntity> SearchForProductsByName(string name)
        {
            var bucket = new RelationPredicateBucket();
            bucket.PredicateExpression.Add(PredicateFactory.Like(ProductFieldIndex.Name, string.Format("%{0}%", name)));

            var productEntities = new EntityCollection(new ProductEntityFactory());

            using (var adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(productEntities, bucket);
            }

            var products = new List<ProductEntity>(productEntities.Count);
            products.AddRange(productEntities.Cast<ProductEntity>());

            return products;
        }
        public static List<ProductSectionEntity> GetChildSections(int parentId)
        {
            EntityCollection sections = new EntityCollection(new ProductSectionEntityFactory());
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(PredicateFactory.CompareValue(ProductSectionFieldIndex.ParentSectionId, ComparisonOperator.Equal, parentId));

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(sections, filter);
            }

            List<ProductSectionEntity> sectionList = new List<ProductSectionEntity>(sections.Count);
            foreach (ProductSectionEntity pse in sections)
            {
                sectionList.Add(pse);
            }

            return sectionList;
        }
        public static string[] FindRolesForUser(string username)
        {
            EntityCollection roles = new EntityCollection(new UserRoleLinkEntityFactory());
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(PredicateFactory.CompareValue(UserRoleLinkFieldIndex.UserId, ComparisonOperator.Equal, username));

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(roles, filter);
            }

            List<string> returnRoles = new List<string>(roles.Items.Count);

            foreach (UserRoleLinkEntity urle in roles)
            {
                returnRoles.Add(urle.RoleName);
            }

            return returnRoles.ToArray();
        }
        public static List<SpecialOfferEntity> GetSpecialOffers(short numberToReturn)
        {
            EntityCollection offers = new EntityCollection(new SpecialOfferEntityFactory());
            IPrefetchPath2 pf = new PrefetchPath2((int)EntityType.SpecialOfferEntity);
            pf.Add(SpecialOfferEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathProductSection);

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(offers, null, numberToReturn, null, pf);
            }

            offers.SupportsSorting = true;
            offers.Sort((int) SpecialOfferFieldIndex.Number, ListSortDirection.Ascending);

            SpecialOfferEntity [] specialOffers = new SpecialOfferEntity[numberToReturn];

            foreach (SpecialOfferEntity sof in offers)
            {
                specialOffers[sof.Number - 1] = sof;
            }

            return FillMissingOffers(specialOffers);
        }
        /// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These entities will have to be persisted after this entity during a recursive save.</summary>
        /// <returns>Collection with 0 or more IEntity2 objects, referenced by this entity</returns>
        public override IEntityCollection2 GetDependingRelatedEntities()
        {
            EntityCollection toReturn = new EntityCollection();

            return toReturn;
        }
        /// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
        /// entities will have to be persisted before this entity during a recursive save.</summary>
        /// <returns>Collection with 0 or more IEntity2 objects, referenced by this entity</returns>
        public override IEntityCollection2 GetDependentRelatedEntities()
        {
            EntityCollection toReturn = new EntityCollection();
            if(_role!=null)
            {
                toReturn.Add(_role);
            }
            if(_user!=null)
            {
                toReturn.Add(_user);
            }

            return toReturn;
        }
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _product = null;
            _productSection_ = null;

            _productSection = null;

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
        /// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
        /// entities will have to be persisted before this entity during a recursive save.</summary>
        /// <returns>Collection with 0 or more IEntity2 objects, referenced by this entity</returns>
        public override IEntityCollection2 GetDependentRelatedEntities()
        {
            EntityCollection toReturn = new EntityCollection();
            if(_productSection!=null)
            {
                toReturn.Add(_productSection);
            }

            return toReturn;
        }
        protected ProductSectionEntity(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _product = (EntityCollection)info.GetValue("_product", typeof(EntityCollection));
            _productSection_ = (EntityCollection)info.GetValue("_productSection_", typeof(EntityCollection));

            _productSection = (ProductSectionEntity)info.GetValue("_productSection", typeof(ProductSectionEntity));
            if(_productSection!=null)
            {
                _productSection.AfterSave+=new EventHandler(OnEntityAfterSave);
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Beispiel #11
0
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _userRoleLink = null;
            _roleCollectionViaUserRoleLink = null;

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Beispiel #12
0
        protected UserEntity(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _userRoleLink = (EntityCollection)info.GetValue("_userRoleLink", typeof(EntityCollection));
            _roleCollectionViaUserRoleLink = (EntityCollection)info.GetValue("_roleCollectionViaUserRoleLink", typeof(EntityCollection));

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _specialOffer = null;
            _productVariation = null;

            _productSection = null;

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
        private static EntityCollection LoadProductsForSection(IRelationPredicateBucket filter)
        {
            EntityCollection products = new EntityCollection(new ProductEntityFactory());
            ISortExpression sorter  = new SortExpression();
            sorter.Add(SortClauseFactory.Create(ProductFieldIndex.SortIndex, SortOperator.Ascending));

            IPrefetchPath2 pfVariations = new PrefetchPath2((int)EntityType.ProductEntity);
            pfVariations.Add(ProductEntity.PrefetchPathProductVariation);

            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(products, filter, 0, sorter, pfVariations);
            }

            return products;
        }