/// <summary>Creates a complete EntityFields instance for the SohEntity.</summary>
		private static IEntityFields2 CreateSohTypedViewEntityFields()
		{
			IEntityFields2 fieldsToReturn = new EntityFields2((int)SohFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("SohTypedView"));
			for(int i=0;i<(int)SohFieldIndex.AmountOfFields;i++)
			{
				fieldsToReturn[i] = EntityFieldFactory.Create((SohFieldIndex)i);
			}
			return fieldsToReturn;
		}
Exemple #2
0
        /// <summary>Creates a complete EntityFields instance for the InvoicesEntity.</summary>
        private static IEntityFields2 CreateInvoicesTypedViewEntityFields()
        {
            IEntityFields2 fieldsToReturn = new EntityFields2((int)InvoicesFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("InvoicesTypedView"));

            for (int i = 0; i < (int)InvoicesFieldIndex.AmountOfFields; i++)
            {
                fieldsToReturn[i] = EntityFieldFactory.Create((InvoicesFieldIndex)i);
            }
            return(fieldsToReturn);
        }
Exemple #3
0
        /// <summary>Creates a complete EntityFields instance for the AlphabeticalListOfProductsEntity.</summary>
        private static IEntityFields2 CreateAlphabeticalListOfProductsTypedViewEntityFields()
        {
            IEntityFields2 fieldsToReturn = new EntityFields2((int)AlphabeticalListOfProductsFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("AlphabeticalListOfProductsTypedView"));

            for (int i = 0; i < (int)AlphabeticalListOfProductsFieldIndex.AmountOfFields; i++)
            {
                fieldsToReturn[i] = EntityFieldFactory.Create((AlphabeticalListOfProductsFieldIndex)i);
            }
            return(fieldsToReturn);
        }
        /// <summary>Creates a complete EntityFields instance for the SummaryOfSalesByYearEntity.</summary>
        private static IEntityFields2 CreateSummaryOfSalesByYearTypedViewEntityFields()
        {
            IEntityFields2 fieldsToReturn = new EntityFields2((int)SummaryOfSalesByYearFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("SummaryOfSalesByYearTypedView"));

            for (int i = 0; i < (int)SummaryOfSalesByYearFieldIndex.AmountOfFields; i++)
            {
                fieldsToReturn[i] = EntityFieldFactory.Create((SummaryOfSalesByYearFieldIndex)i);
            }
            return(fieldsToReturn);
        }
        /// <summary>Creates a complete EntityFields instance for the ProductsAboveAveragePriceEntity.</summary>
        private static IEntityFields2 CreateProductsAboveAveragePriceTypedViewEntityFields()
        {
            IEntityFields2 fieldsToReturn = new EntityFields2((int)ProductsAboveAveragePriceFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("ProductsAboveAveragePriceTypedView"));

            for (int i = 0; i < (int)ProductsAboveAveragePriceFieldIndex.AmountOfFields; i++)
            {
                fieldsToReturn[i] = EntityFieldFactory.Create((ProductsAboveAveragePriceFieldIndex)i);
            }
            return(fieldsToReturn);
        }
        /// <summary>Creates a complete EntityFields instance for the CustomerAndSuppliersByCityEntity.</summary>
        private static IEntityFields2 CreateCustomerAndSuppliersByCityTypedViewEntityFields()
        {
            IEntityFields2 fieldsToReturn = new EntityFields2((int)CustomerAndSuppliersByCityFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("CustomerAndSuppliersByCityTypedView"));

            for (int i = 0; i < (int)CustomerAndSuppliersByCityFieldIndex.AmountOfFields; i++)
            {
                fieldsToReturn[i] = EntityFieldFactory.Create((CustomerAndSuppliersByCityFieldIndex)i);
            }
            return(fieldsToReturn);
        }
 /// <summary>Creates a complete EntityFields instance for the ProductEntity.</summary>
 private static IEntityFields2 CreateProductEntityFields()
 {
     IEntityFields2 fieldsToReturn = new EntityFields2((int)ProductFieldIndex.AmountOfFields, InheritanceInfoProviderSingleton.GetInstance());
     for(int i=0;i<(int)ProductFieldIndex.AmountOfFields;i++)
     {
         fieldsToReturn[i] = EntityFieldFactory.Create((ProductFieldIndex)i);
     }
     return fieldsToReturn;
 }
 /// <summary>Creates a complete EntityFields instance for the ProductsAboveAveragePriceEntity.</summary>
 private static IEntityFields2 CreateProductsAboveAveragePriceTypedViewEntityFields()
 {
     IEntityFields2 fieldsToReturn = new EntityFields2((int)ProductsAboveAveragePriceFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("ProductsAboveAveragePriceTypedView"));
     for(int i=0;i<(int)ProductsAboveAveragePriceFieldIndex.AmountOfFields;i++)
     {
         fieldsToReturn[i] = EntityFieldFactory.Create((ProductsAboveAveragePriceFieldIndex)i);
     }
     return fieldsToReturn;
 }
 /// <summary>Creates a complete EntityFields instance for the CustomerAndSuppliersByCityEntity.</summary>
 private static IEntityFields2 CreateCustomerAndSuppliersByCityTypedViewEntityFields()
 {
     IEntityFields2 fieldsToReturn = new EntityFields2((int)CustomerAndSuppliersByCityFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("CustomerAndSuppliersByCityTypedView"));
     for(int i=0;i<(int)CustomerAndSuppliersByCityFieldIndex.AmountOfFields;i++)
     {
         fieldsToReturn[i] = EntityFieldFactory.Create((CustomerAndSuppliersByCityFieldIndex)i);
     }
     return fieldsToReturn;
 }
 /// <summary>Creates a complete EntityFields instance for the AlphabeticalListOfProductsEntity.</summary>
 private static IEntityFields2 CreateAlphabeticalListOfProductsTypedViewEntityFields()
 {
     IEntityFields2 fieldsToReturn = new EntityFields2((int)AlphabeticalListOfProductsFieldIndex.AmountOfFields, null, FieldInfoProviderSingleton.GetInstance().GetFieldIndexes("AlphabeticalListOfProductsTypedView"));
     for(int i=0;i<(int)AlphabeticalListOfProductsFieldIndex.AmountOfFields;i++)
     {
         fieldsToReturn[i] = EntityFieldFactory.Create((AlphabeticalListOfProductsFieldIndex)i);
     }
     return fieldsToReturn;
 }
        /// <summary>
        /// Retrieves a list of groups matching the criteria specified via method parameters.
        /// </summary>
        /// <param name="category">Category name.</param>
        /// <param name="categoryId">Category Id</param>
        /// <param name="pageNumber">Page number.</param>
        /// <param name="pageSize">Page size.</param>
        /// <param name="recordCount">Record count.</param>
        /// <returns>List of groups.</returns>
        public List<MonoSoftware.MonoX.Repositories.SnGroupDTO> GetPopularGroups(string category, Guid categoryId, int pageNumber, int pageSize, out int recordCount)
        {
            RelationPredicateBucket filter = new RelationPredicateBucket();

            //introduced to filter out groups by languages and applications
            filter.Relations.Add(SnGroupEntity.Relations.SnGroupCategoryEntityUsingGroupCategoryId, JoinHint.Left);
            //Note: MonoX supports the multi application environment so general filter for all DB access calls should contain the application id filter
            filter.PredicateExpression.Add(SnGroupCategoryFields.ApplicationId == MonoSoftware.MonoX.Repositories.MembershipRepository.GetInstance().GetApplicationId());
            //Note: MonoX in supports the multi language environment so general filter for all DB access calls should contain the language id filter
            filter.PredicateExpression.Add(SnGroupCategoryFields.LanguageId == LocalizationUtility.GetCurrentLanguageId());

            //Filter groups by category
            if (categoryId != Guid.Empty)
            {
                filter.PredicateExpression.Add(SnGroupFields.GroupCategoryId == categoryId);
            }
            if (!String.IsNullOrEmpty(category))
            {
                filter.PredicateExpression.Add(SnGroupCategoryFields.Slug == category);
            }

            IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.SnGroupEntity);
            prefetch.Add(SnGroupEntity.PrefetchPathSnGroupCategory);
            //Fetch a record from the members table only for the current user so his status could be read
            Guid uid = SecurityUtility.GetUserId();
            if (!Guid.Empty.Equals(uid))
            {
                PredicateExpression memberFilter = new PredicateExpression(SnGroupMemberFields.UserId == uid);
                prefetch.Add(SnGroupEntity.PrefetchPathSnGroupMembers, 1, memberFilter);
            }

            #region Popular groups sorter
            const string memberCountField = "MemberCountField";
            const string memberCountTableName = "MemberCountTable";

            EntityFields2 memberFields = new EntityFields2(2);
            memberFields.DefineField(SnGroupMemberFields.GroupId, 0);
            memberFields.DefineField(SnGroupMemberFields.Id, 1, memberCountField, AggregateFunction.Count);
            DerivedTableDefinition memberCountTable = new DerivedTableDefinition(memberFields, memberCountTableName, null, new GroupByCollection(memberFields[0]));

            IDynamicRelation memberCountRelation = new DynamicRelation(memberCountTable, JoinHint.Right, MonoSoftware.MonoX.DAL.EntityType.SnGroupEntity, String.Empty, SnGroupMemberFields.GroupId.SetObjectAlias(memberCountTable.Alias) == SnGroupFields.Id);
            filter.Relations.Add(memberCountRelation);

            ISortExpression sorter = new SortExpression(new SortClause(new EntityField2(memberCountField, null).SetObjectAlias(memberCountTableName), null, SortOperator.Descending));
            #endregion

            EntityCollection<SnGroupEntity> groups = new EntityCollection<SnGroupEntity>();
            //Fetch the group collection
            FetchEntityCollection(groups, filter, 0, sorter, prefetch, pageNumber, pageSize);
            //Fetch the group total count used by paging
            recordCount = GetDbCount(groups, filter);
            //Transfer group entities to the DTO
            List<MonoSoftware.MonoX.Repositories.SnGroupDTO> toReturn = groups.Select(group => new MonoSoftware.MonoX.Repositories.SnGroupDTO(group)).ToList<MonoSoftware.MonoX.Repositories.SnGroupDTO>();
            return toReturn;
        }