private void OnProductCategoryBindingSourceCurrentItemChanged(object sender, System.EventArgs e) { _currentProductCategory = uxProductCategoryBindingSource.Current as Entities.ProductCategory; if (_currentProductCategory != null) { _currentProductCategory.Validate(); } //_ProductCategory.Validate(); OnCurrentEntityChanged(); }
public static int DepthLevel(this Entities.ProductCategory category) { Entities.ProductCategory tempCategory = category; int depth = -1; while (tempCategory != null) { depth++; tempCategory = tempCategory.ParentCategory; } return(depth); }
public ProductCategoryRepositoryTests() { var contaxt = new DataLayer.InventoryDBContext(); var relateduser = contaxt.Users.FirstOrDefault(u => u.Username.Equals("admin")); var identity = new GenericIdentity(relateduser.Username); var roles = relateduser.Roles.Select(p => p.Title).ToArray(); var principal = new GenericPrincipal(identity, roles); System.Threading.Thread.CurrentPrincipal = principal; procat = new ProductCategoryRepository(); Eprocat = new Entities.ProductCategory() { SubProductCategoryID = 0, InventoryId = 1, Title = "Title", Description = "Description", Capacity = 1, }; }
public static string FullCategoryPath(this Entities.ProductCategory category, string separator) { StringBuilder sb = new StringBuilder(); Stack <Entities.ProductCategory> categories = new Stack <Entities.ProductCategory>(); Entities.ProductCategory tempCategory = category; while (tempCategory != null) { categories.Push(tempCategory); tempCategory = tempCategory.ParentCategory; } while (categories.Count > 0) { sb.Append(categories.Pop().CategoryName); if (categories.Count > 0) { sb.Append(separator); } } return(sb.ToString()); }
private IEnumerable <TreeControlNode <Entities.ProductCategory> > TreeControl_OnGetNode(TreeNode parent, Entities.ProductCategory obj) { List <TreeControlNode <Entities.ProductCategory> > nodes = new List <TreeControlNode <Entities.ProductCategory> >(); if (parent == null) { var rootCategories = CatRep.GetByParent(); return(rootCategories.Select(cat => new TreeControlNode <Entities.ProductCategory>() { Text = cat.Title, Object = cat, })); } else { var parentCategory = obj; var rootCategories = CatRep.GetByParent(parentCategory.ProductCategoryId); return(rootCategories.Select(cat => new TreeControlNode <Entities.ProductCategory>() { Text = cat.Title, Object = cat, })); } }
private void OnProductCategoryBindingSourceCurrentItemChanged(object sender, System.EventArgs e) { _currentProductCategory = uxProductCategoryBindingSource.Current as Entities.ProductCategory; if (_currentProductCategory != null) { _currentProductCategory.Validate(); } //_ProductCategory.Validate(); OnCurrentEntityChanged(); }