public Task <List <CategoryBase> > GetCategoryLOV() { SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Get_Category"; var reader = cmd.ExecuteReader(); List <CategoryBase> categories = new List <CategoryBase>(); while (reader.Read()) { CategoryBase category = new CategoryBase(); category.Id = Convert.ToInt32(reader["Category_Id"]); category.CategoryName = Convert.ToString(reader["CategoryName"]); categories.Add(category); } conn.Close(); return(Task.FromResult(categories)); }
private string GetDisplayName(CategoryBase item) { var result = String.Empty; var category = item as Category; if (category != null) { result = category.Name; } else { var linkedCategory = (LinkedCategory)item; if (linkedCategory != null) { var link = linkedCategory.CategoryLink; if (link != null) { result = (link is Category) ? String.Format("{0} ({1})", ((Category)link).Name, linkedCategory.LinkedCatalogId) : String.Format("{0} ({1})", link.CategoryId, linkedCategory.LinkedCatalogId); } } } return(result); }
private void RaisePriorityChangeInteractionRequest(string parameter) { var moveUp = parameter == "up"; var parentHierarchyVM = (HierarchyViewModelBase)Parent; var indexThis = parentHierarchyVM.ChildrenModels.IndexOf(this); if ((moveUp && indexThis > 0) || (!moveUp && indexThis < parentHierarchyVM.ChildrenModels.Count - 1)) { var indexNext = indexThis + (moveUp ? -1 : 1); var siblingVM = (ITreeCategoryViewModel)parentHierarchyVM.ChildrenModels[indexNext]; using (var repository = _repositoryFactory.GetRepositoryInstance()) { _innerItem = repository.Categories.Where(x => x.CategoryId == _innerItem.CategoryId).First(); var siblingItem = repository.Categories.Where(x => x.CategoryId == siblingVM.InnerItem.CategoryId).First(); var tmpPriority = _innerItem.Priority; if (_innerItem.Priority == siblingItem.Priority) { _innerItem.Priority = siblingItem.Priority + (moveUp ? 1 : -1); } else { _innerItem.Priority = siblingItem.Priority; } siblingItem.Priority = tmpPriority; repository.UnitOfWork.Commit(); } parentHierarchyVM.Refresh(); } }
public PriceCalculation Get(Provider provider, CategoryBase categoryBase, int level) { ICriteria crit = GetCriteria(); if (provider != null) { crit.Add(Expression.Eq("Provider", provider)); } else { crit.Add(Expression.IsNull("Provider")); } if (categoryBase != null) { crit.Add(Expression.Eq("CategoryBase", categoryBase)); } else { crit.Add(Expression.IsNull("CategoryBase")); } //if(level > -1) crit.Add(Expression.Eq("Level", level)); return(crit.UniqueResult <PriceCalculation>()); }
public void SetParent(object child, object parent) { using (var repository = _repositoryFactory.GetRepositoryInstance()) { _innerItem = repository.Categories.Where(x => x.CategoryId == _innerItem.CategoryId).First(); if (parent is ITreeCategoryViewModel) { var targetCategoryVM = parent as ITreeCategoryViewModel; InnerItem.ParentCategoryId = targetCategoryVM.InnerItem.CategoryId; // InnerItem.ParentCategory = targetCategoryVM.InnerItem; Parent = targetCategoryVM; } else if (parent is ITreeCatalogViewModel || parent is ITreeVirtualCatalogViewModel) { // var targetCatalogVM = parent as ICatalogViewModel; InnerItem.ParentCategoryId = null; InnerItem.ParentCategory = null; //InnerItem.Catalog = targetCatalogVM.InnerCatalog; //InnerItem.CatalogId = targetCatalogVM.InnerCatalog.CatalogId; Parent = (IViewModel)parent; } repository.UnitOfWork.Commit(); } }
/// <summary> /// Creates the category model. /// </summary> /// <param name="category">The category.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">category</exception> public static CategoryModel CreateCategoryModel(CategoryBase category) { if (category == null) { throw new ArgumentNullException("category"); } var model = new CategoryModel { Category = category }; model.InjectFrom(category); model.LinkedCategories = new List<LinkedCategory>(category.LinkedCategories).ToArray(); model.CatalogOutline = CatalogClient.BuildCategoryOutline(UserHelper.CustomerSession.CatalogId, category); if (category is Category) { var realCat = category as Category; model.CategoryPropertyValues = new List<CategoryPropertyValue>(realCat.CategoryPropertyValues).ToArray(); if (realCat.PropertySet != null && realCat.CategoryPropertyValues != null) { var values = realCat.CategoryPropertyValues; var properties = realCat.PropertySet.PropertySetProperties.SelectMany(x => values.Where(v => v.Name == x.Property.Name && !x.Property.PropertyAttributes.Any(pa => pa.PropertyAttributeName.Equals("Hidden", StringComparison.OrdinalIgnoreCase)) && (!x.Property.IsLocaleDependant || string.Equals(v.Locale, CultureInfo.CurrentUICulture.Name, StringComparison.InvariantCultureIgnoreCase))), (r, v) => CreatePropertyModel(r.Priority, r.Property, v, category)).ToArray(); model.Properties = new PropertiesModel(properties); } } return model; }
public async ValueTask <IActionResult> Post([FromBody] CategoryBase model) { if (ModelState.IsValid) { var checker = await _repo.Item().Where(c => c.Name.Equals(model.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefaultAsync(); if (checker != null) { return(BadRequest(new ErrorDTO { Message = "Category already exists" })); } Category category = model.Convert <CategoryBase, Category>(_mapper); (bool succeeded, Category addedCategory, string error) = await _repo.Add(category); if (succeeded) { return(Ok(addedCategory.Convert <Category, CategoryBase>(_mapper))); } return(BadRequest(new ErrorDTO { Message = error })); } return(BadRequest(new ErrorDTO { Errors = ModelState.Values.SelectMany(e => e.Errors).ToList() })); }
protected void rpterCategory_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { CategoryBase f = (e.Item.DataItem as CategoryBase); HyperLink hl = (e.Item.FindControl("lnkGo") as HyperLink); if (f != null) { hl.NavigateUrl = "/categorys/view/default.aspx?Id=" + f.ID; hl.Text = f.Name; hl.ToolTip = string.Format("Ingresar a la categoría {0}", f.Name); (e.Item.FindControl("litDescription") as Literal).Text = StringFormat.FormatHasValue(f.Description); if (f.Parent != null) { (e.Item.FindControl("litParent") as Literal).Text = StringFormat.FormatHasValue(f.Parent.Name); } else { (e.Item.FindControl("litParent") as Literal).Text = "N/D"; } } } }
private CategoryBase GetCategoryByIdInternal(string catalogId, string id) { //Get simple category CategoryBase category = _catalogRepository.Categories.OfType <Category>() .Expand(c => c.LinkedCategories) .Expand(c => c.CategoryPropertyValues) .FirstOrDefault(x => x.CategoryId.Equals(id, StringComparison.OrdinalIgnoreCase) && (string.IsNullOrEmpty(catalogId) || x.CatalogId.Equals(catalogId, StringComparison.OrdinalIgnoreCase))); if (category == null) { //Get linked category category = _catalogRepository.Categories.OfType <LinkedCategory>() .Expand(c => c.LinkedCategories) .FirstOrDefault(x => x.CategoryId.Equals(id, StringComparison.OrdinalIgnoreCase) && (string.IsNullOrEmpty(catalogId) || x.CatalogId.Equals(catalogId, StringComparison.OrdinalIgnoreCase))); if (category != null && category.IsActive) { //Get simple category from linked catalog var realCategory = _catalogRepository.Categories.OfType <Category>() .Expand(p => p.CategoryPropertyValues) .FirstOrDefault(x => (x.CatalogId == ((LinkedCategory)category).LinkedCatalogId) && (x.CategoryId.Equals(id, StringComparison.OrdinalIgnoreCase))); if (realCategory != null) { return(realCategory); } } } return(category); }
public List <PriceCalculation> Get(Provider provider, CategoryBase categoryBase) { if (provider == null && categoryBase == null) { return(new List <PriceCalculation>()); } ICriteria crit = GetCriteria(); if (provider != null) { crit.Add(Expression.Eq("Provider", provider)); } else { crit.Add(Expression.IsNull("Provider")); } if (categoryBase != null) { crit.Add(Expression.Eq("CategoryBase", categoryBase)); } else { crit.Add(Expression.IsNull("CategoryBase")); } return(crit.List <PriceCalculation>() as List <PriceCalculation>); }
private void Load() { var startPosition = Categories.Count == 0 ? 0 : Categories.Count; for (int i = startPosition; i < startPosition + 25; i++) { CategoryBase category = new CategoryBase(); category.Name = $"Category{i + 1}"; var itemsCount = rnd.Next(1, 11); for (int j = 0; j < itemsCount; j++) { CategoryItemBase items = new CategoryItemBase(); var itemNumber = rnd.Next(1, 31); var name = $"Item{itemNumber}"; var isExist = category.Items.Any(item => item.Name == name); while (isExist) { itemNumber = rnd.Next(1, 31); name = $"Item{itemNumber}"; isExist = category.Items.Any(item => item.Name == name); } items.Name = name; category.Items.Add(items); } Categories.Add(category); } }
private static void AssertAreEqualCategories <TCategory>(CategoryBase <TCategory> expectedCategory, CategoryBase <TCategory> calculatedCategory) { Assert.AreEqual(expectedCategory.Category, calculatedCategory.Category); AssertAreEqualProbabilities(expectedCategory.LowerLimit, calculatedCategory.LowerLimit); AssertAreEqualProbabilities(expectedCategory.UpperLimit, calculatedCategory.UpperLimit); }
public void Run(Provider provider, CategoryBase category) { int?providerId = null; int?categoryId = null; if (provider != null) { providerId = provider.ID; } if (category != null) { categoryId = category.ID; } #if !DEBUG // Indicates which method to execute ProcessItem processItem = new ProcessItem(Guid.NewGuid().ToString()); processItem.AssemblyName = typeof(PriceCalculator).Assembly.FullName; processItem.ClassName = typeof(PriceCalculator).FullName; processItem.ConstructorParameters = new object[] { true, MembershipHelper.GetUser().UserId }; processItem.MethodName = "Run"; processItem.MethodParameters = new object[] { providerId, categoryId }; // Add the task for processing whenever possible DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor); processor.AddTask(processItem); #else new PriceCalculator(true, MembershipHelper.GetUser().UserId).Run(providerId, categoryId); #endif }
public void UpdateCategoryBase(CategoryBase categoryBase) { var category = _mapper.Map <CategoryBase, Category>(categoryBase); _categoryRepository .Update(category); _categoryRepository.Save(); }
protected void AssertAreEqualCategories <TCategory>(TCategory expectedCategory, double expectedLowerLimit, double expectedUpperLimit, CategoryBase <TCategory> assessmentSectionCategory) { Assert.AreEqual(expectedCategory, assessmentSectionCategory.Category); AssertAreEqualProbabilities(expectedLowerLimit, assessmentSectionCategory.LowerLimit); AssertAreEqualProbabilities(expectedUpperLimit, assessmentSectionCategory.UpperLimit); }
public override bool Equals(CategoryBase other) { if(!base.Equals(other)) return false; AlgebraicStructureCategory asc = other as AlgebraicStructureCategory; if(asc == null) return false; return _structure.Equals(asc._structure) && _additiveEntity.Equals(asc._additiveEntity) && _multiplicativeEntity.Equals(asc._multiplicativeEntity); }
public void AddMethodTest() { CategoryBase model = new CategoryBase(); model.CategoryName = "생활용품"; var r = _repository.Add(model); Assert.AreEqual(r.CategoryName, model.CategoryName); }
public override void Delete(PriceCalculation priceCalculation) { Provider p = priceCalculation.Provider; CategoryBase c = priceCalculation.CategoryBase; NHibernateSession.Delete(priceCalculation); CommitChanges(); Run(p, c); }
public CategorySeoViewModel(ILoginViewModel loginViewModel, ICatalogOutlineBuilder catalogBuilder, IRepositoryFactory <IStoreRepository> storeRepositoryFactory, IRepositoryFactory <IAppConfigRepository> appConfigRepositoryFactory, IAppConfigEntityFactory appConfigEntityFactory, Category item, IEnumerable <string> languages, CatalogBase parentCatalog) : base(appConfigRepositoryFactory, appConfigEntityFactory, parentCatalog.DefaultLanguage, languages, item.CategoryId, SeoUrlKeywordTypes.Category) { _storeRepositoryFactory = storeRepositoryFactory; _catalogBuilder = catalogBuilder; _loginViewModel = loginViewModel; _category = item; _catalog = parentCatalog; InitializePropertiesForViewing(); }
public override bool Equals(CategoryBase other) { if (!base.Equals(other)) { return(false); } AlgebraicStructureCategory asc = other as AlgebraicStructureCategory; if (asc == null) { return(false); } return(_structure.Equals(asc._structure) && _additiveEntity.Equals(asc._additiveEntity) && _multiplicativeEntity.Equals(asc._multiplicativeEntity)); }
public Product(Guid id, string name, string shortDescription, string description, decimal price, Brand brand, CategoryBase category, string mainImage, FakeProductDiscount fakeProductDiscount) { Id = id; Name = name; MainImage = mainImage; ShortDescription = shortDescription; Description = description; Price = price; IsActive = true; Brand = brand; Category = category; CreationTime = DateTime.Now; Discount = fakeProductDiscount; }
public CatalogOutline BuildCategoryOutline(string catalogId, CategoryBase category, bool useCache = true) { // recurring adding elements var categories = new List <CategoryBase>(); var outline = new CatalogOutline { CatalogId = catalogId }; if (category != null) { BuildCategoryOutline(ref categories, catalogId, category, useCache); outline.Categories.AddRange(categories); } return(outline); }
public UpdateCategory(CategoryEditDto categoryEditDto, CategoryBase categoryBase) { InitializeComponent(); this._categoryBase = categoryBase; categoryController = new CategoryController(categoryService); categoryName.Text = categoryEditDto.categoryName; categoryLimit.Text = categoryEditDto.categoryLimit.ToString(); categoryId = categoryEditDto.categoryId; comboBox1.Items.Add(new KeyValuePair <string, int>("Income", 0)); comboBox1.Items.Add(new KeyValuePair <string, int>("Expense", 1)); comboBox1.DisplayMember = "key"; comboBox1.ValueMember = "value"; comboBox1.Text = categoryEditDto.categoryType; }
protected void LoadFields() { if (CategoryId != 0) { CategoryBase cb = ControllerManager.CategoryBase.GetById(CategoryId); txtName.Text = cb.Name; txtDescripcion.Text = cb.Description; if (cb.GetType().AssemblyQualifiedName == typeof(Family).AssemblyQualifiedName) { ddlType.Value = "1"; } else if (cb.GetType().AssemblyQualifiedName == typeof(CatalogPage).AssemblyQualifiedName) { ddlType.Value = "2"; } else if (cb.GetType().AssemblyQualifiedName == typeof(ProductType).AssemblyQualifiedName) { ddlType.Value = "3"; } else if (cb.GetType().AssemblyQualifiedName == typeof(Application).AssemblyQualifiedName) { ddlType.Value = "4"; } else if (cb.GetType().AssemblyQualifiedName == typeof(Line).AssemblyQualifiedName) { ddlType.Value = "5"; } else if (cb.GetType().AssemblyQualifiedName == typeof(Area).AssemblyQualifiedName) { ddlType.Value = "6"; } txtDescriptionEnglish.Text = cb.DescripionEnglish; txtNameEnglish.Text = cb.NameEnglish; txtObservations.Text = cb.Observations; if (!string.IsNullOrEmpty(cb.Image)) { imgImage.ImageUrl = Path.Combine(Config.ImagesProductsPath, cb.Image); } else { imgImage.Visible = false; } } }
public override string GetTitle() { if (!string.IsNullOrEmpty(Request.QueryString["Id"])) { int id = Convert.ToInt32(Request.QueryString["Id"]); CategoryBase c = ControllerManager.CategoryBase.GetById(id); if (c != null) { return(c.Name.ToString()); } return(Resource.Business.GetString("CategoryTitle")); } return(Resource.Business.GetString("CategoryTitle")); }
public void Run(MasterPriceSearchParameters mpsp, GridState gs, int categoryId, bool addCategory) { CategoryBase tempcb = null; if (addCategory) { tempcb = new CategoryBase(categoryId); } IList <PriceBase> temppblist = ControllerManager.PriceBase.GetPriceBases( mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, string.Empty, string.Empty, gs.MarkedAll, gs.Items, false, mpsp.Currency, null, tempcb, null, mpsp.Provider, mpsp.SearchDate, PriceBaseStatus.NotVerified, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor); if (temppblist.Count > 0) { priceBases = temppblist; Execute(); } }
public void EditMethodTest() { var model = new CategoryBase { CategoryId = 0, CategoryName = "BOOKS" }; var isEdited = _repository.Edit(model); if (isEdited) { Console.WriteLine("수정했습니다."); } else { Console.WriteLine("수정하지 못했습니다."); } }
private CategoryBase CreateCategory(string name, Type selectedType) { CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(name); CategoryBase categoryBase = (CategoryBase)CategoryFactory.GetCustomCategorySelector(canonicalCategoryName).CreateSceneNodeCategory(canonicalCategoryName, name, this.SceneNodeObjectSet.DesignerContext.MessageLoggingService); ITypeResolver typeResolver = (ITypeResolver)this.SceneNodeObjectSet.ProjectContext; CategoryEditorSet categoryEditorsList = new CategoryEditorSet(); IType type = typeResolver.GetType(selectedType); PropertyInspectorModel.GetCategoryEditors(type, categoryEditorsList, this.MessageLoggingService); foreach (CategoryEditor categoryEditor in categoryEditorsList.Union(CategoryEditorInstanceFactory.GetEditors((ITypeId)type, categoryBase as SceneNodeCategory))) { if (categoryEditor.TargetCategory == categoryBase.CategoryName) { categoryBase.CategoryEditors.Add(categoryEditor); } } return(categoryBase); }
public bool HaveCategory(CategoryBase cb) { ICriteria crit = GetCriteria(); if (cb != null) { crit.Add(Expression.Eq("CategoryBase", cb)); } if (crit.List <PriceCalculation>().Count > 0) { return(true); } else { return(false); } }
public TreeCategoryViewModel( CategoryBase item, IRepositoryFactory <IAppConfigRepository> seoRepositoryFactory, IRepositoryFactory <ICatalogRepository> repositoryFactory, IViewModelsFactory <ICategoryViewModel> categoryVmFactory, IViewModelsFactory <ILinkedCategoryViewModel> linkedCategoryVmFactory, IViewModelsFactory <ITreeCategoryViewModel> treeCategoryVmFactory, IAuthenticationContext authContext, INavigationManager navigationManager) : base(repositoryFactory, authContext) { _treeCategoryVmFactory = treeCategoryVmFactory; _seoRepositoryFactory = seoRepositoryFactory; InnerItem = item; EmbeddedHierarchyEntry = this; ViewTitle = new ViewTitleBase { Title = "Category", SubTitle = GetDisplayName(item).ToUpper(CultureInfo.InvariantCulture) }; PriorityChangeCommand = new DelegateCommand <string>(RaisePriorityChangeInteractionRequest); OpenItemCommand = new DelegateCommand(() => { if (NavigationData == null) { var param = new KeyValuePair <string, object>("item", InnerItem); IViewModel editVM; if (InnerItem is Category) { editVM = categoryVmFactory.GetViewModelInstance(param, new KeyValuePair <string, object>("parentTreeVM", this)); } else { editVM = linkedCategoryVmFactory.GetViewModelInstance(param); } NavigationData = ((IClosable)editVM).NavigationData; } navigationManager.Navigate(NavigationData); }); }
private void InitializeDataAsync() { var ctx = SynchronizationContext.Current; ThreadPool.QueueUserWorkItem(state => { // this runs in a separate thread: var bcRoot = Domain.Nodes; var categories = new CategoryBase[] { Domain.RootCategory }; var rootFolders = new NodeBase[] { Domain.RootFolder }; var rootCategory = Domain.RootCategory; ctx.Post(ctxState => { // this runs in the application thread: categoriesTree.SelectFirst(); }, null); }); }
public MaterialPageBySearchList FindMaterialPageBySearchListByQDT(int PageIndex, int PageSize, string Keyword, string MatBrand, Guid CatID, string IsStatUs) { var query = (from M in db.Material where true select M).AsQueryable(); //品牌判断 if (!string.IsNullOrEmpty(MatBrand)) { query = query.Where(m => m.MatBrand.Contains(MatBrand)).AsQueryable(); } ICategory ICat = new CategoryBase(); CatTree CT = ICat.GetCatTreeByQDT(); //分类判断 if (CatID != Guid.Empty) { if (CT.SecondCatTree.Where(c => c.CatID == CatID).Count() > 0) { query = query.Where(c => c.LinkQDTCatID == CatID).AsQueryable(); } } //发布 新品 置顶判断 if (IsStatUs == MatISNo.IsPublic.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsNotPublic.ToString()) { query = query.Where(x => x.IsPublic == 0 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsTop.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsTop == 1 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsNotTop.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsTop == 0 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsNew.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsNew == 1 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsNotNew.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsNew == 0 && x.GroupToMatID == Guid.Empty).AsQueryable(); } else if (IsStatUs == MatISNo.IsPromotion.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 1 && x.IsGroupMat <= 0).AsQueryable(); } else if (IsStatUs == MatISNo.IsNotPromotion.ToString()) { query = query.Where(x => x.IsPublic == 1 && x.IsPromotion == 0 && x.IsGroupMat <= 0).AsQueryable(); } if (!string.IsNullOrEmpty(Keyword)) { Keyword = Regex.Replace(Keyword, @"( )\1+", "$1", RegexOptions.None); string[] KeywordStr = Keyword.Split(' '); foreach (var K in KeywordStr) { if (!string.IsNullOrEmpty(K)) { query = query.Where( m => m.MatSn.Contains(K) || m.MatBrand.Contains(K) || m.MatManufacturerSn.Contains(K) || m.MatSpecifications.Contains(K) || m.MatName.Contains(K) || m.KeywordIndex.Contains(K) ).AsQueryable(); } } } //获取以过滤的品牌项 var queryBrand = query.Where(x => x.MatBrandID != Guid.Empty).GroupBy(x => x.MatBrandID).Select(x => x.Key).AsQueryable(); List<P_Brand> PBL = new List<P_Brand>(); P_Brand PB = new P_Brand(); Brand B = new Brand(); foreach (var x in queryBrand) { B = db.Brand.Find(x); if (B != null) { PB = new P_Brand(); PB.BID = B.BID; PB.BrandName = B.BrandName; PB.BrandEnName = B.BrandNameEn; PB.BrandLogo = B.BrandLogo; PBL.Add(PB); }else{ PB = new P_Brand(); PB.BID = Guid.Empty; PB.BrandName = string.Empty; PB.BrandEnName = string.Empty; PB.BrandLogo = string.Empty; PBL.Add(PB); } } List<P_Brand> PBLNew = new List<P_Brand>(); var QueryBrandNew = from x in PBL where true && x.BID != Guid.Empty && x.BrandLogo != string.Empty && x.BrandName != string.Empty group x by x.BrandName into g select new { BID = g.FirstOrDefault().BID, BrandLogo = g.FirstOrDefault().BrandLogo, BrandName = g.FirstOrDefault().BrandName, BrandEnName = g.FirstOrDefault().BrandEnName, }; P_Brand NewB = new P_Brand(); foreach(var x in QueryBrandNew) { NewB = new P_Brand(); NewB.BID = x.BID; NewB.BrandLogo = x.BrandLogo; NewB.BrandEnName = x.BrandEnName; NewB.BrandName = x.BrandName; PBLNew.Add(NewB); } //获取以过滤分类项 var queryCat = from x in query where true && x.CategoryID != Guid.Empty && x.LinkQDTCatID != Guid.Empty group x by x.LinkQDTCatID into g select new { CID = g.Key, Count = g.Count() }; List<P_Cat> PCL = new List<P_Cat>(); P_Cat PC = new P_Cat(); Category Cat = new Category(); foreach (var x in queryCat) { PC = new P_Cat(); if (CT.SecondCatTree.Where(c => c.CatID == x.CID).Count() > 0) { PC.CatID = x.CID; PC.CatCount = x.Count; PC.CatName = CT.SecondCatTree.Where(c => c.CatID == x.CID).FirstOrDefault().CategoryName; PCL.Add(PC); } } List<Material> ML = query.OrderByDescending(s => s.LastUpdateTime).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); List<Material> SubGroupML = new List<Material>(); IBrand IB = new BrandBase(); string MaxPrice = string.Empty; string MinPrice = string.Empty; foreach (var x in ML) { x.MoreDetail = string.Empty; if (x.IsGroupMat > 0) { SubGroupML = this.GetMaterialByGroupMatID(Guid.Empty, x.MatID); x.LinkGroupMatCount = SubGroupML.Count(); try { MaxPrice = SubGroupML.Where(c => c.PriceInfo.SalesPrice > 0).Max(c => c.PriceInfo.SalesPrice).ToString("N"); MinPrice = SubGroupML.Where(c => c.PriceInfo.SalesPrice > 0).Min(c => c.PriceInfo.SalesPrice).ToString("N"); if (MaxPrice != MinPrice) { x.LinkGroupPrice = MinPrice + " ~ " + MaxPrice; } else { x.LinkGroupPrice = MinPrice; } } catch { x.LinkGroupPrice = string.Empty; } } } ML = IB.GetMatSalesPriceInfoList(ML, Guid.Empty); MaterialPageBySearchList MP = new MaterialPageBySearchList(); MP.PageIndex = PageIndex; MP.PageSize = PageSize; MP.TotalRecord = query.Count(); MP.Rows = ML; MP.Brand = PBLNew; MP.Cat = PCL; return MP; }
public MaterialPageBySearchList FindMaterialPageByIsGroupSearchList(int PageIndex, int PageSize, string Keyword, Guid LinkMainCID) { var query = (from M in db.Material where true && M.LinkMainCID.Equals(LinkMainCID) && M.IsGroupMat == 1 select M).AsQueryable(); if (!string.IsNullOrEmpty(Keyword)) { Keyword = Regex.Replace(Keyword, @"( )\1+", "$1", RegexOptions.None); string[] KeywordStr = Keyword.Split(' '); foreach (var K in KeywordStr) { if (!string.IsNullOrEmpty(K)) { query = query.Where( m => m.MatSn.Contains(K) || m.MatBrand.Contains(K) || m.MatManufacturerSn.Contains(K) || m.MatSpecifications.Contains(K) || m.MatName.Contains(K) || m.KeywordIndex.Contains(K) ).AsQueryable(); } } } //获取以过滤的品牌项 var queryBrand = query.Where(x => x.MatBrandID != Guid.Empty).GroupBy(x => x.MatBrandID).Select(x => x.Key).AsQueryable(); List<P_Brand> PBL = new List<P_Brand>(); P_Brand PB = new P_Brand(); Brand B = new Brand(); foreach (var x in queryBrand) { B = db.Brand.Find(x); if (B != null) { PB = new P_Brand(); PB.BID = B.BID; PB.BrandName = B.BrandName; PB.BrandEnName = B.BrandNameEn; PB.BrandLogo = B.BrandLogo; PBL.Add(PB); } } //获取以过滤分类项 var queryCat = from x in query where true && x.CategoryID != Guid.Empty group x by x.CategoryID into g select new { CID = g.Key, Count = g.Count() }; ICategory IC = new CategoryBase(); CatTree CT = IC.GetCatTree(LinkMainCID); List<P_Cat> PCL = new List<P_Cat>(); P_Cat PC = new P_Cat(); Category Cat = new Category(); foreach (var x in queryCat) { PC = new P_Cat(); if (CT.TopCatTree.Where(c => c.CatID == x.CID).Count() > 0) { PC.CatID = x.CID; PC.CatCount = x.Count; PC.CatName = CT.TopCatTree.Where(c => c.CatID == x.CID).FirstOrDefault().CategoryName; PCL.Add(PC); } else if (CT.SecondCatTree.Where(c => c.CatID == x.CID).Count() > 0) { PC.CatID = x.CID; PC.CatCount = x.Count; PC.CatName = CT.SecondCatTree.Where(c => c.CatID == x.CID).FirstOrDefault().CategoryName; PCL.Add(PC); } else if (CT.EndCatTree.Where(c => c.CatID == x.CID).Count() > 0) { PC.CatID = x.CID; PC.CatCount = x.Count; PC.CatName = CT.EndCatTree.Where(c => c.CatID == x.CID).FirstOrDefault().CategoryName; PCL.Add(PC); } } List<Material> ML = query.OrderByDescending(s => s.LastUpdateTime).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); foreach (var x in ML) { x.MoreDetail = string.Empty; x.LinkGroupMatCount = db.Material.Where(c => c.GroupToMatID == x.MatID).Count(); } MaterialPageBySearchList MP = new MaterialPageBySearchList(); MP.PageIndex = PageIndex; MP.PageSize = PageSize; MP.TotalRecord = query.Count(); MP.Rows = ML; MP.Brand = PBL; MP.Cat = PCL; return MP; }
public void UpdateMaterialCatID(List<Guid> MatIDList, Guid CatID, Guid LinkMainCID) { string CatNameStr = string.Empty; ICategory IC = new CategoryBase(); CatTree C = IC.GetCatTree(LinkMainCID); string NamePath = string.Empty; if(C.TopCatTree.Where(x=>x.CatID == CatID).FirstOrDefault() != null) { NamePath = C.TopCatTree.Where(x => x.CatID == CatID).FirstOrDefault().CategoryNamePath; } if (C.SecondCatTree.Where(x => x.CatID == CatID).FirstOrDefault() != null) { NamePath = C.SecondCatTree.Where(x => x.CatID == CatID).FirstOrDefault().CategoryNamePath; } if (C.EndCatTree.Where(x => x.CatID == CatID).FirstOrDefault() != null) { NamePath = C.EndCatTree.Where(x => x.CatID == CatID).FirstOrDefault().CategoryNamePath; } if(CatID == Guid.Empty) { CatNameStr = string.Empty; } else { CatNameStr = NamePath; } Material M = new Material(); foreach (var x in MatIDList) { try { M = db.Material.Find(x); M.CategoryID = CatID; M.CategoryName = CatNameStr; db.Entry(M).State = EntityState.Modified; } catch { //Dothing } } db.SaveChanges(); }