public ProductCollection GetProductsByKeywordAndBaseCatId(string keyword, int baseCatId) { int baseCategoryId = baseCatId; ProductCollection productList = new ProductCollection(); IPrefetchPath prefetchCategory = new PrefetchPath((int)EntityType.ProductEntity); prefetchCategory.Add(ProductEntity.PrefetchPathCategory); RelationCollection relations = new RelationCollection(); relations.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId); relations.Add(ProductEntity.Relations.ProductKeywordEntityUsingProductId); relations.Add(KeywordEntity.Relations.ProductKeywordEntityUsingKeywordId); IPredicateExpression filter = new PredicateExpression(); filter.Add(new FieldLikePredicate(KeywordFields.Keyword, null, "%" + keyword + "%")); filter.Add(CategoryFields.BaseCategoryId == baseCategoryId); productList.GetMulti(filter, 0, null, relations, prefetchCategory); return(productList); }
public ActionResult EditPolicySet(policyData vData, int id) { SortExpression se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.PolicyLinkEntity); pp.Add(PolicyLinkEntity.PrefetchPathChildren, 0, null, null, se); vData.PolicyLink = new PolicyLinkEntity(id, pp); vData.PolicySet = vData.PolicyLink.Policy; return(View(vData)); }
public CategoryCollection GetSubCategories(int mainCatId) { CategoryCollection subCategories = new CategoryCollection(); PredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.CategoryEntity); prefetchPath.Add(CategoryEntity.PrefetchPathCategories); filter.Add(CategoryFields.BaseCategoryId == mainCatId); subCategories.GetMulti(filter, prefetchPath); return(subCategories); }
public ActionResult EditPolicy(policyData vData, int id) { vData.PolicyLink = new PolicyLinkEntity(id); SortExpression se = new SortExpression(RuleFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.PolicyEntity); pp.Add(PolicyEntity.PrefetchPathRule, 0, null, null, se); vData.Policy = new PolicyEntity(vData.PolicyLink.PolicyId, pp); return(View(vData)); }
public ActionResult EditRule(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.RuleEntity); pp.Add(RuleEntity.PrefetchPathCondition).SubPath.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se); vData.Rule = new RuleEntity(id, pp); vData.Condition = vData.Rule.Condition; return(View(vData)); }
public ActionResult EditCondition(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity); pp.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se); vData.Condition = new DecisionNodeEntity(id, pp); ViewData["title"] = "edit condition"; return(View(vData)); }
public ProductCollection GetDetailedProduct(int pid) { IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true); prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords); prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications); prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos); ProductEntity p = new ProductEntity(pid, prefatchPath); ProductCollection col = new ProductCollection(); col.Add(p); return(col); }
/// <summary> /// Gets all IP ban entities, sorted by range for the page specified. /// </summary> /// <param name="pageNo">The page number for the page to read. Specify 0 to fetch all ip bans.</param> /// <param name="pageSize">Size of the page to fetch. Specify 0 to fetch all ip bans.</param> /// <param name="prefetchUser">If set to true, it will prefetch the user entity into the ipBan entity, for the user who set the IPBan</param> /// <returns> /// the collection of ipban entities requested /// </returns> public static IPBanCollection GetAllIPBans(int pageNo, int pageSize, bool prefetchUser) { IPBanCollection toReturn = new IPBanCollection(); PrefetchPath path = null; if (prefetchUser) { // build the Prefetch path to fetch the user as well path = new PrefetchPath((int)EntityType.IPBanEntity); path.Add(IPBanEntity.PrefetchPathSetByUser); } toReturn.GetMulti(null, 0, new SortExpression(IPBanFields.Range.Ascending()), null, path, pageNo, pageSize); return(toReturn); }
/// <summary> /// Returns the user entity of the user with ID userID, With A UserEntityTitle prefetched. /// </summary> /// <param name="userID">The user ID.</param> /// <returns>entity with data requested</returns> public static UserEntity GetUserWithTitleDescription(int userID) { PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity); prefetchPath.Add(UserEntity.PrefetchPathUserTitle); UserEntity user = new UserEntity(userID, prefetchPath); if (user.IsNew) { // not found return(null); } return(user); }
public static EmployeeCollection GetEmployees() { var relations = new RelationCollection { EmployeeEntityBase.Relations.ContactEntityUsingContactID }; ISortExpression lastFirstAlpha = (ContactFields.LastName | SortOperator.Ascending) & (ContactFields.FirstName | SortOperator.Ascending); var employees = new EmployeeCollection(); IPrefetchPath prefetch = new PrefetchPath((int)EntityType.EmployeeEntity) { EmployeeEntityBase.PrefetchPathContact }; var includeFields = new IncludeFieldsList(ContactFields.LastName, ContactFields.FirstName, EmployeeFields.EmployeeID); employees.GetMulti(null, 0, lastFirstAlpha, relations, prefetch, includeFields, 0, 0); return(employees); }
public object GetProductsByBrandId(int bid) { ProductCollection productList = new ProductCollection(); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.BrandEntityUsingBrandId); IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathBrand); PredicateExpression filter = new PredicateExpression(); filter.Add(BrandFields.Id == bid); productList.GetMulti(filter, 0, null, relation, prefatchPath); return(productList); }
public ProductCollection GetProductsByMainCategoryId(int baseCatId) { int baseCategoryId = baseCatId; ProductCollection productList = new ProductCollection(); IPredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); prefetchPath.Add(ProductEntity.PrefetchPathCategory); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId); filter.Add(CategoryFields.BaseCategoryId == baseCategoryId); productList.GetMulti(filter, 0, null, relation, prefetchPath); return(productList); }
public ProductCollection GetProductsByStoreId(int storeId) { int strId = storeId; ProductCollection productList = new ProductCollection(); IPredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); prefetchPath.Add(ProductEntity.PrefetchPathStore); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.StoreEntityUsingStoreId); filter.Add(StoreFields.Id == strId); productList.GetMulti(filter, 0, null, relation, prefetchPath); return(productList); }
public ActionResult EditMatch(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(AttributeValueFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity); pp.Add(DecisionNodeEntity.PrefetchPathAttributeValue, 0, null, null, se); vData.DecisionNode = new DecisionNodeEntity(id, pp); ViewData["title"] = "edit match"; // if (vData.DecisionNode.Parent.Rule.Count > 0) ViewData["selectList"] = vData.allAttributes(vData.DecisionNode.AttributeId); //else // ViewData["selectList"] = vData.subjectAttributes(vData.DecisionNode.AttributeId); return(View(vData)); }
public ProductCollection GetSliderProducts() { ProductCollection sliderProducts = new ProductCollection(); PredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); IPrefetchPathElement path = prefetchPath.Add(ProductEntity.PrefetchPathComments); path.SubPath.Add(CommentEntity.PrefetchPathRate); filter.Add(ProductFields.IsSliderProduct == true); filter.Add(ProductFields.Status == true); sliderProducts.GetMulti(filter, prefetchPath); foreach (var item in sliderProducts) { int id = item.Id; } return(sliderProducts); }
/// <summary> /// Gets the support queue thread info entity and if specified, prefetches the user entity which claimed the related thread. /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="prefetchClaimUser">if set to true it will </param> /// <returns>fetched entity if found, otherwise null</returns> public static SupportQueueThreadEntity GetSupportQueueThreadInfo(int threadID, bool prefetchClaimUser) { SupportQueueThreadEntity toReturn = new SupportQueueThreadEntity(); PrefetchPath path = null; if (prefetchClaimUser) { // prefetch the user who claimed this thread (if any) path = new PrefetchPath((int)EntityType.SupportQueueThreadEntity); path.Add(SupportQueueThreadEntity.PrefetchPathClaimedByUser); } // now fetch the entity using the unique constraint on Thread by specifying the threadID passed in. Also specify the prefetch path (if any) toReturn.FetchUsingUCThreadID(threadID, path); if (toReturn.IsNew) { // not found return(null); } return(toReturn); }
/// <summary> /// Authenticates the user with the given Nickname and the given Password. /// </summary> /// <param name="nickName">Nickname of the user</param> /// <param name="password">Password of the user</param> /// <returns>AuthenticateResult.AllOk if the user could be authenticated, /// AuthenticateResult.WrongUsernamePassword if user couldn't be authenticated given the current credentials, /// AuthenticateResult.IsBanned if the user is banned. </returns> public static AuthenticateResult AuthenticateUser(string nickName, string password, out UserEntity user) { // fetch the Roles related to the user when fetching the user, using a prefetchPath object. PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity); prefetchPath.Add(UserEntity.PrefetchPathRoles); // fetch the user data using the nickname which has a unique constraint user = new UserEntity(); bool fetchResult = user.FetchUsingUCNickName(nickName, prefetchPath); if (!fetchResult) { // not found. Simply return that the user has specified a wrong username/password combination. return(AuthenticateResult.WrongUsernamePassword); } // user was found, check if the user can be authenticated and has specified the correct password. if (user.IsBanned) { // user is banned. We'll report that to the caller return(AuthenticateResult.IsBanned); } else { // check password and UserID. We disallow the user with id 0 to login as that's the anonymous coward ID for a user not logged in. string md5HashedPassword = HnDGeneralUtils.CreateMD5HashedBase64String(password); if ((md5HashedPassword == user.Password) && (user.UserID != Globals.UserIDToDenyLogin)) { // correct username/password combination return(AuthenticateResult.AllOk); } else { // something was wrong, report wrong authentication combination return(AuthenticateResult.WrongUsernamePassword); } } }
public LastViewedProductCollection GetLast5ViewedProducts(int storeId) { LastViewedProductCollection lastViewedProducts = new LastViewedProductCollection(); RelationCollection relationsToUse = new RelationCollection(); relationsToUse.Add(LastViewedProductEntity.Relations.ProductEntityUsingProductId); relationsToUse.Add(ProductEntity.Relations.StoreEntityUsingStoreId); PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.LastViewedProductEntity); prefetchPath.Add(LastViewedProductEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathStore); PredicateExpression filter = new PredicateExpression(); filter.Add(StoreFields.Id == storeId); SortExpression sorter = new SortExpression(); sorter.Add(LastViewedProductFields.ViewedTime | SortOperator.Descending); lastViewedProducts.GetMulti(filter, 5, sorter, relationsToUse, prefetchPath); return(lastViewedProducts); }
//public ProductCollection SortProductsByRate(ProductCollection productList, bool isAscending) //{ //} public ProductCollection GetLast5AddedProducts(object m) { MembershipEntity member = new MembershipEntity(3); ProductCollection products = new ProductCollection(); RelationCollection relations = new RelationCollection(); relations.Add(ProductEntity.Relations.StoreEntityUsingStoreId); relations.Add(StoreEntity.Relations.MembershipEntityUsingMembershipId); IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathStore).SubPath.Add(StoreEntity.PrefetchPathMembership); PredicateExpression filter = new PredicateExpression(); filter.Add(MembershipFields.Id == member.Id); SortExpression sorter = new SortExpression(); sorter.Add(ProductFields.AddedDate | SortOperator.Descending); products.GetMulti(filter, 5, sorter, relations, prefatchPath); return(products); }
/// <summary> /// Gets the prefetch path for a Manager's Employees. By using this prefetch all a manager's employees a bought back in 1 query. /// </summary> /// <returns></returns> public static IPrefetchPath GetManagesPrefetchPath() { IPrefetchPath prefetch = new PrefetchPath((int)EntityType.EmployeeEntity) { EmployeeEntityBase.PrefetchPathContact }; prefetch.Add(EmployeeEntityBase.PrefetchPathManages) .SubPath.Add(EmployeeEntityBase.PrefetchPathManages) .SubPath.Add(EmployeeEntityBase.PrefetchPathManages) .SubPath.Add(EmployeeEntityBase.PrefetchPathManages) .SubPath.Add(EmployeeEntityBase.PrefetchPathManages); prefetch[1].SubPath.Add(EmployeeEntityBase.PrefetchPathContact); prefetch[1].SubPath[0].SubPath.Add( EmployeeEntityBase.PrefetchPathContact); prefetch[1].SubPath[0].SubPath[0].SubPath.Add( EmployeeEntityBase.PrefetchPathContact); prefetch[1].SubPath[0].SubPath[0].SubPath[0].SubPath.Add( EmployeeEntityBase.PrefetchPathContact); prefetch[1].SubPath[0].SubPath[0].SubPath[0].SubPath[0].SubPath.Add( EmployeeEntityBase.PrefetchPathContact); return(prefetch); }
public ProductCollection GetProductsByMainCategoryId(int baseCatId) { int baseCategoryId = baseCatId; ProductCollection productList = new ProductCollection(); IPredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); prefetchPath.Add(ProductEntity.PrefetchPathCategory); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId); filter.Add(CategoryFields.BaseCategoryId == baseCategoryId); productList.GetMulti(filter, 0, null, relation, prefetchPath); return productList; }
public ProductCollection GetProductsByKeywordAndBaseCatId(string keyword, int baseCatId) { int baseCategoryId = baseCatId; ProductCollection productList = new ProductCollection(); IPrefetchPath prefetchCategory = new PrefetchPath((int)EntityType.ProductEntity); prefetchCategory.Add(ProductEntity.PrefetchPathCategory); RelationCollection relations = new RelationCollection(); relations.Add(ProductEntity.Relations.CategoryEntityUsingCategoryId); relations.Add(ProductEntity.Relations.ProductKeywordEntityUsingProductId); relations.Add(KeywordEntity.Relations.ProductKeywordEntityUsingKeywordId); IPredicateExpression filter = new PredicateExpression(); filter.Add(new FieldLikePredicate(KeywordFields.Keyword, null, "%" + keyword + "%")); filter.Add(CategoryFields.BaseCategoryId == baseCategoryId); productList.GetMulti(filter, 0, null, relations, prefetchCategory); return productList; }
public object GetProductsByBrandId(int bid) { ProductCollection productList = new ProductCollection(); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.BrandEntityUsingBrandId); IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathBrand); PredicateExpression filter = new PredicateExpression(); filter.Add(BrandFields.Id == bid); productList.GetMulti(filter, 0, null, relation, prefatchPath); return productList; }
public LastViewedProductCollection GetLast5ViewedProducts(int storeId) { LastViewedProductCollection lastViewedProducts = new LastViewedProductCollection(); RelationCollection relationsToUse = new RelationCollection(); relationsToUse.Add(LastViewedProductEntity.Relations.ProductEntityUsingProductId); relationsToUse.Add(ProductEntity.Relations.StoreEntityUsingStoreId); PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.LastViewedProductEntity); prefetchPath.Add(LastViewedProductEntity.PrefetchPathProduct).SubPath.Add(ProductEntity.PrefetchPathStore); PredicateExpression filter = new PredicateExpression(); filter.Add(StoreFields.Id == storeId); SortExpression sorter = new SortExpression(); sorter.Add( LastViewedProductFields.ViewedTime | SortOperator.Descending); lastViewedProducts.GetMulti(filter, 5, sorter, relationsToUse, prefetchPath); return lastViewedProducts; }
//public ProductCollection SortProductsByRate(ProductCollection productList, bool isAscending) //{ //} public ProductCollection GetLast5AddedProducts(object m) { MembershipEntity member = new MembershipEntity(3); ProductCollection products = new ProductCollection(); RelationCollection relations = new RelationCollection(); relations.Add(ProductEntity.Relations.StoreEntityUsingStoreId); relations.Add(StoreEntity.Relations.MembershipEntityUsingMembershipId); IPrefetchPath prefatchPath = new PrefetchPath((int)EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathStore).SubPath.Add(StoreEntity.PrefetchPathMembership); PredicateExpression filter = new PredicateExpression(); filter.Add(MembershipFields.Id == member.Id); SortExpression sorter = new SortExpression(); sorter.Add(ProductFields.AddedDate | SortOperator.Descending); products.GetMulti(filter, 5, sorter, relations, prefatchPath); return products; }
public ActionResult EditPolicySet(policyData vData, int id) { SortExpression se = new SortExpression(PolicyLinkFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.PolicyLinkEntity); pp.Add(PolicyLinkEntity.PrefetchPathChildren, 0, null, null, se); vData.PolicyLink = new PolicyLinkEntity(id,pp); vData.PolicySet = vData.PolicyLink.Policy; return View(vData); }
public ActionResult EditRule(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.RuleEntity); pp.Add(RuleEntity.PrefetchPathCondition).SubPath.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se); vData.Rule = new RuleEntity(id, pp); vData.Condition = vData.Rule.Condition; return View(vData); }
public ActionResult EditTarget(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity); pp.Add(DecisionNodeEntity.PrefetchPathChildren, 0, null, null, se); vData.Condition = new DecisionNodeEntity(id,pp); ViewData["title"] = "edit target condition"; return View(vData); }
/// <summary> /// Calculates the statistics for the Northwind database and shows them in the form, illustrating the /// direct database power LLBLGen Pro offers you through scalar functions, aggregates, group by and expressions. /// </summary> /// <remarks>No error checking is applied to this routine, it's for illustrating the framework functionality.</remarks> private void CalculateStatistics() { // get amount customers CustomerCollection customers = new CustomerCollection(); int amountCustomers = customers.GetDbCount(); _amountCustomersTextBox.Text = amountCustomers.ToString(); // get all order prices ResultsetFields orderPricesFields = new ResultsetFields(2); orderPricesFields.DefineField(OrderDetailFields.OrderId, 0, "OrderId"); orderPricesFields.DefineField(OrderDetailFields.ProductId, 1, "OrderPrice", "", AggregateFunction.Sum); orderPricesFields[1].ExpressionToApply = (OrderDetailFields.Quantity * OrderDetailFields.UnitPrice); IGroupByCollection groupBy = new GroupByCollection(); groupBy.Add(orderPricesFields[0]); // fetch in a datatable, orderid + the order price. DataTable orderPrices = new DataTable(); TypedListDAO dao = new TypedListDAO(); dao.GetMultiAsDataTable(orderPricesFields, orderPrices, 0, null, null, null, true, groupBy, null, 0, 0); // calculate average order price and which customer has the most expensive order decimal averageOrderPrice = 0.0M; decimal highestOrderPrice = 0.0M; int orderIdWithHighestPrice = 0; for (int i = 0; i < orderPrices.Rows.Count; i++) { decimal currentOrderPrice = (decimal)orderPrices.Rows[i]["OrderPrice"]; if (currentOrderPrice > highestOrderPrice) { highestOrderPrice = currentOrderPrice; orderIdWithHighestPrice = (int)orderPrices.Rows[i]["OrderId"]; } averageOrderPrice += currentOrderPrice; } averageOrderPrice = averageOrderPrice / orderPrices.Rows.Count; _highestOrderPriceTextBox.Text = highestOrderPrice.ToString("C"); _averageOrderPriceTextBox.Text = averageOrderPrice.ToString("C"); // get order with highest price. Pull customer also in 1 go IPrefetchPath prefetchPathCustomer = new PrefetchPath((int)EntityType.OrderEntity); prefetchPathCustomer.Add(OrderEntity.PrefetchPathCustomer); OrderEntity highestOrder = new OrderEntity(); highestOrder.FetchUsingPK(orderIdWithHighestPrice, prefetchPathCustomer); _customerWithHighestOrder = highestOrder.Customer; // already loaded through prefetch path. _highestOrderCustomerTextBox.Text = _customerWithHighestOrder.CompanyName; // get customer with most orders. ResultsetFields orderCustomerFields = new ResultsetFields(2); orderCustomerFields.DefineField(OrderFields.CustomerId, 0, "CustomerID"); orderCustomerFields.DefineField(OrderFields.OrderId, 1, "AmountOrders", "", AggregateFunction.Count); groupBy = new GroupByCollection(); groupBy.Add(orderCustomerFields[0]); SortExpression sorter = new SortExpression(); sorter.Add(new SortClause(orderCustomerFields[1], SortOperator.Descending)); // now fetch the list, just 1 row, ordered descending on amount DataTable orderCustomer = new DataTable(); dao.GetMultiAsDataTable(orderCustomerFields, orderCustomer, 1, sorter, null, null, true, groupBy, null, 0, 0); _mostOrdersPerCustomerTextBox.Text = orderCustomer.Rows[0]["AmountOrders"].ToString(); // we'll assume the data was there, so there is a row. _customerWithMostOrders = new CustomerEntity(orderCustomer.Rows[0]["CustomerID"].ToString()); _mostOrdersCustomerTextBox.Text = _customerWithMostOrders.CompanyName; }
public ActionResult EditPolicy(policyData vData, int id) { vData.PolicyLink = new PolicyLinkEntity(id); SortExpression se = new SortExpression(RuleFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.PolicyEntity); pp.Add(PolicyEntity.PrefetchPathRule, 0, null, null, se); vData.Policy = new PolicyEntity(vData.PolicyLink.PolicyId,pp); return View(vData); }
/// <summary> /// Returns the user entity of the user with ID userID, With A UserEntityTitle prefetched. /// </summary> /// <param name="userID">The user ID.</param> /// <returns>entity with data requested</returns> public static UserEntity GetUserWithTitleDescription(int userID) { PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity); prefetchPath.Add(UserEntity.PrefetchPathUserTitle); UserEntity user = new UserEntity(userID, prefetchPath); if(user.IsNew) { // not found return null; } return user; }
/// <summary> /// Gets the support queue thread info entity and if specified, prefetches the user entity which claimed the related thread. /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="prefetchClaimUser">if set to true it will </param> /// <returns>fetched entity if found, otherwise null</returns> public static SupportQueueThreadEntity GetSupportQueueThreadInfo(int threadID, bool prefetchClaimUser) { SupportQueueThreadEntity toReturn = new SupportQueueThreadEntity(); PrefetchPath path = null; if(prefetchClaimUser) { // prefetch the user who claimed this thread (if any) path = new PrefetchPath((int)EntityType.SupportQueueThreadEntity); path.Add(SupportQueueThreadEntity.PrefetchPathClaimedByUser); } // now fetch the entity using the unique constraint on Thread by specifying the threadID passed in. Also specify the prefetch path (if any) toReturn.FetchUsingUCThreadID(threadID, path); if(toReturn.IsNew) { // not found return null; } return toReturn; }
public ProductCollection GetProductsByStoreId(int storeId) { int strId = storeId; ProductCollection productList = new ProductCollection(); IPredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); prefetchPath.Add(ProductEntity.PrefetchPathStore); RelationCollection relation = new RelationCollection(); relation.Add(ProductEntity.Relations.StoreEntityUsingStoreId); filter.Add(StoreFields.Id == strId); productList.GetMulti(filter, 0, null, relation, prefetchPath); return productList; }
public ActionResult EditMatch(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); SortExpression se = new SortExpression(AttributeValueFields.Order | SortOperator.Ascending); PrefetchPath pp = new PrefetchPath(EntityType.DecisionNodeEntity); pp.Add(DecisionNodeEntity.PrefetchPathAttributeValue, 0, null, null, se); vData.DecisionNode = new DecisionNodeEntity(id,pp); ViewData["title"] = "edit match"; // if (vData.DecisionNode.Parent.Rule.Count > 0) ViewData["selectList"] = vData.allAttributes(vData.DecisionNode.AttributeId); //else // ViewData["selectList"] = vData.subjectAttributes(vData.DecisionNode.AttributeId); return View(vData); }
public ProductCollection GetSliderProducts() { ProductCollection sliderProducts = new ProductCollection(); PredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.ProductEntity); IPrefetchPathElement path = prefetchPath.Add(ProductEntity.PrefetchPathComments); path.SubPath.Add(CommentEntity.PrefetchPathRate); filter.Add(ProductFields.IsSliderProduct == true); filter.Add(ProductFields.Status == true); sliderProducts.GetMulti(filter, prefetchPath); foreach (var item in sliderProducts) { int id = item.Id; } return sliderProducts; }
public ProductCollection GetDetailedProduct(int pid) { IPrefetchPath prefatchPath = new PrefetchPath(EntityType.ProductEntity); prefatchPath.Add(ProductEntity.PrefetchPathComments).Filter.Add(CommentFields.Status == true); prefatchPath.Add(ProductEntity.PrefetchPathProductKeywords); prefatchPath.Add(ProductEntity.PrefetchPathProductSpecifications); prefatchPath.Add(ProductEntity.PrefetchPathProductPhotos); ProductEntity p = new ProductEntity(pid, prefatchPath); ProductCollection col = new ProductCollection(); col.Add(p); return col; }
public CategoryCollection GetSubCategories(int mainCatId) { CategoryCollection subCategories = new CategoryCollection(); PredicateExpression filter = new PredicateExpression(); IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.CategoryEntity); prefetchPath.Add(CategoryEntity.PrefetchPathCategories); filter.Add(CategoryFields.BaseCategoryId == mainCatId); subCategories.GetMulti(filter, prefetchPath); return subCategories; }
/// <summary> /// Authenticates the user with the given Nickname and the given Password. /// </summary> /// <param name="nickName">Nickname of the user</param> /// <param name="password">Password of the user</param> /// <returns>AuthenticateResult.AllOk if the user could be authenticated, /// AuthenticateResult.WrongUsernamePassword if user couldn't be authenticated given the current credentials, /// AuthenticateResult.IsBanned if the user is banned. </returns> public static AuthenticateResult AuthenticateUser(string nickName, string password, out UserEntity user) { // fetch the Roles related to the user when fetching the user, using a prefetchPath object. PrefetchPath prefetchPath = new PrefetchPath((int)EntityType.UserEntity); prefetchPath.Add(UserEntity.PrefetchPathRoles); // fetch the user data using the nickname which has a unique constraint user = new UserEntity(); bool fetchResult = user.FetchUsingUCNickName(nickName, prefetchPath); if(!fetchResult) { // not found. Simply return that the user has specified a wrong username/password combination. return AuthenticateResult.WrongUsernamePassword; } // user was found, check if the user can be authenticated and has specified the correct password. if(user.IsBanned) { // user is banned. We'll report that to the caller return AuthenticateResult.IsBanned; } else { // check password and UserID. We disallow the user with id 0 to login as that's the anonymous coward ID for a user not logged in. string md5HashedPassword = HnDGeneralUtils.CreateMD5HashedBase64String(password); if((md5HashedPassword == user.Password)&&(user.UserID != Globals.UserIDToDenyLogin)) { // correct username/password combination return AuthenticateResult.AllOk; } else { // something was wrong, report wrong authentication combination return AuthenticateResult.WrongUsernamePassword; } } }