public ActionResult Subgroup(SearchSubgroupsFilters filters)
        {
            BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"];
            bool fromFullText        = false;

            if (nav.LastNavigable == "FullSearch")
            {
                fromFullText = true;
            }

            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);

            SubgroupsModel model = _subgroupBinder.GetSubgroupsModel(new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "SourceId", Order = SortOrder.Ascending
            }), filters, materialContextUow);

            if (model.Materials.Count == 1 && fromFullText)
            {
                return(RedirectToAction("GetMaterialDetails", "MaterialDetails", new { materialId = model.Materials[0].MaterialId, subgroupId = model.Materials[0].SubgroupId, sourceId = model.Materials[0].SourceId, sourceMaterialId = model.Materials[0].SourceMaterialId, searchText = model.Filters.FullText, tabId = "divProperties" }));
            }

            model.ChemicalElsProperties = new ElsevierMaterialsMVC.BL.Binders.PropertyDescriptionBinder().GetProperties(filters.MaterialId, materialContextUow);

            return(View("Subgroups", model));
        }
        public ActionResult ClearSubgroupTableFilters(SearchSubgroupsFilters filters)
        {
            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);
            SubgroupsModel model = _subgroupBinder.GetSubgroupsModel(new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "SourceId", Order = SortOrder.Ascending
            }), filters, materialContextUow);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("EquivalentMaterials", model), JsonRequestBehavior.AllowGet));
        }
        public ActionResult SubgroupBySourceMaterialId(int sourceId, int sourceMaterialId)
        {
            SearchSubgroupsFilters filters = new SearchSubgroupsFilters();

            filters.MaterialId = materialContextUow.Materials.AllAsNoTracking.Where(m => m.SourceId == sourceId && m.SourceMaterialId == sourceMaterialId).Select(m => m.MaterialId).FirstOrDefault();

            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);
            SubgroupsModel model = _subgroupBinder.GetSubgroupsModel(new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "SourceId", Order = SortOrder.Ascending
            }), filters, materialContextUow);

            model.ChemicalElsProperties = new ElsevierMaterialsMVC.BL.Binders.PropertyDescriptionBinder().GetProperties(filters.MaterialId, materialContextUow);
            return(View("Subgroups", model));
        }
Пример #4
0
        public SearchSubgroupsFilters BreadcrumbNavigationGetSet(SearchSubgroupsFilters filters)
        {
            BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"];

            if (nav == null)
            {
                nav = new BreadcrumbNavigation();
            }

            if (nav.Contains("Exporter"))
            {
                nav.Pop();
            }
            if (nav.Contains("Comparison"))
            {
                nav.Pop();
            }
            if (nav.Contains("MaterialDetails1"))
            {
                nav.Pop();
            }

            ElsevierMaterialsMVC.BL.Global.Subgroups hp = nav.GetOrderedItems().Where(n => n.NavigableID == "Subgroups").FirstOrDefault() as ElsevierMaterialsMVC.BL.Global.Subgroups;
            if (hp == null)
            {
                hp          = new ElsevierMaterialsMVC.BL.Global.Subgroups();
                hp.PageData = filters;
            }
            else
            {
                if (filters.MaterialId == 0)
                {
                    filters = hp.PageData as SearchSubgroupsFilters;
                }
                else
                {
                    hp.PageData = filters;
                }
            }

            nav.LastNavigable = "Subgroups";
            hp.IsVisible      = true;
            nav.Push(hp);

            System.Web.HttpContext.Current.Session["Navigation"] = nav;
            return(filters);
        }
        public ActionResult ApplySubgroupTableFilters(GridDescriptor request, SearchSubgroupsFilters filters)
        {
            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);
            SubgroupsModel model = null;

            if (request == null || (request != null && request.Pager == null) || (request != null && request.Sort != null && request.Sort.PropertyName == null))
            {
                model = _subgroupBinder.GetSubgroupsModel(new GridDescriptor(new SortDescriptor()
                {
                    PropertyName = "SourceText", Order = SortOrder.Ascending
                }), filters, materialContextUow);
            }
            else
            {
                model = _subgroupBinder.GetSubgroupsModel(request, filters, materialContextUow);
            }

            return(Json(ResponseStatus.Success, RenderPartialViewToString("SubgroupResults", model), JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public SubgroupsModel GetSubgroupsModel(GridDescriptor request, SearchSubgroupsFilters filters, IMaterialsContextUow context)
        {
            SubgroupsModel model = new SubgroupsModel();

            model.Descriptor = request;
            ICollection <Material> materials = GetAllEquivalentMaterialsEn(filters.MaterialId, context);

            model.MaterialInfo = materials.FirstOrDefault();
            var standardList = materials.Select(m => new PropertyGroupModel {
                PropertyGroupModelName = m.Standard
            }).Distinct(new PropertyGroupComparer()).OrderBy(m => m.PropertyGroupModelName).ToList();

            var sourcesInitial = materials.Select(m => string.Concat(m.SourceId, "#", m.DatabookId)).Distinct();



            int databookId = 0;

            if (filters.SourceId > 0)
            {
                bool isInt = int.TryParse(filters.Source.Split('#')[1], out databookId);
                databookId = isInt ? databookId : 0;

                materials = materials.Where(m => m.SourceId == filters.SourceId && m.DatabookId == databookId).ToList();
            }

            if (filters.StandardId != null && filters.StandardId != "" && filters.StandardId != "0")
            {
                materials = materials.Where(m => m.Standard == filters.StandardId).ToList();
            }

            if (filters.Specification != "" && filters.Specification != null)
            {
                materials = materials.Where(m => m.Specification.ToLower().Contains(filters.Specification.ToLower())).ToList();
            }

            IEnumerable <Material> materialsEnum = materials.AsEnumerable();

            SearchFilterColumnsAll columnFilters = (SearchFilterColumnsAll)System.Web.HttpContext.Current.Session["SubgroupListResults"];

            if (columnFilters != null)
            {
                foreach (SearchFilterColumns f in columnFilters.AllFilters.Where(c => c.Filter != null && c.Filter.Trim() != ""))
                {
                    string oneFilter = f.Filter.Trim().ToUpper();
                    if (f.Name == "Reference")
                    {
                        materialsEnum = materialsEnum.Where(m => m.SourceText != null && m.SourceText.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Supplier")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Manufacturer != null && m.Manufacturer.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Std. Org. / Country")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Standard != null && m.Standard.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Specification")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Specification != null && m.Specification.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Filler")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Filler != null && m.Filler.ToUpper().Contains(oneFilter));
                    }
                }
            }

            model.Materials = materialsEnum.ToList();
            model.Descriptor.Pager.TotalRecordCount = model.Materials.Count;
            model.Descriptor = request;
            if (model.Materials.Count > 0)
            {
                model.Name = model.Materials[0].Name;
            }
            else
            {
                model.Name = "";
            }


            SearchSubgroupCondition filterModel = new SearchSubgroupCondition();

            filterModel.SourceId              = filters.SourceId;
            filterModel.StandardId            = filters.StandardId;
            filterModel.Specification         = filters.Specification;
            filterModel.FullText              = filters.filter;
            filterModel.ShowPropertiesFilters = false;
            //IEnumerable<string> subSources = sourcesInitial.Select(m => string.Concat(m.SourceId, "#", m.DatabookId)).Distinct();
            filterModel.Sources = context.Sources.AllAsNoTracking.Where(s =>
                                                                        s.Id == 0 || /* for All */
                                                                        sourcesInitial.Contains(string.Concat(s.Id, "#", s.Databook_id))
                                                                        ).ToList();
            filterModel.PropertyGroups        = standardList;
            filterModel.MaterialId            = filters.MaterialId;
            filterModel.ShowPropertiesFilters = false;
            filterModel.FromBrowse            = filters.FromBrowse;
            filterModel.FromAdvanced          = filters.FromAdvanced;
            filterModel.SelectedSource        = filters.Source;

            model.Filters = filterModel;
            return(model);
        }