Exemplo n.º 1
0
        public ActionResult EditForm(int? id)
        {
            var obj = new ProductFilterItem();

            var listProductType = productFilterRepository.GetListForTree<object>();

            if (id.HasValue)
                obj = productFilterRepository.GetItemById<ProductFilterItem>(id.Value);

            return Json(new
            {
                data = obj,
                listType = listProductType
            }, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 2
0
        public ActionResult EditForm(int?id)
        {
            var obj = new ProductFilterItem();

            var listProductType = productFilterRepository.GetListForTree <object>();

            if (id.HasValue)
            {
                obj = productFilterRepository.GetItemById <ProductFilterItem>(id.Value);
            }

            return(Json(new
            {
                data = obj,
                listType = listProductType
            }, JsonRequestBehavior.AllowGet));
        }
        public IList <IProductFilter> FindAllFilters(IUser currentUser, IProductListInputModel query)
        {
            // Find the list of products
            string url = "ProductService.svc/rest/ListProductFilters2?";

            url += addUserUrlDetails(currentUser);

            url += "&statusSeed=" + _configuration["Storm:StatusSeed"];

            if (query.CategoryIds != null)
            {
                url += "&categorySeed=" + string.Join(",", query.CategoryIds);
            }

            if (query.FlagIds != null)
            {
                url += "&flagSeed=" + string.Join(",", query.FlagIds);
            }
            if (!string.IsNullOrEmpty(query.Query))
            {
                url += "&searchString=" + System.Web.HttpUtility.UrlEncode(query.Query);
            }


            var filterList = _connectionManager.GetResult <List <StormFilter> >(url);

            List <IProductFilter> result = new List <IProductFilter>();

            Dictionary <string, ProductDto> variants = new Dictionary <string, ProductDto>();

            foreach (var item in filterList)
            {
                var dto = new ProductFilterDto();

                dto.Items = new List <IProductFilterItem>();
                dto.Name  = item.Type;
                dto.Type  = item.Name;

                if (item.Name.Equals("parf"))
                {
                    foreach (var entry in item.Items)
                    {
                        dto       = new ProductFilterDto();
                        dto.Items = new List <IProductFilterItem>();
                        dto.Name  = entry.Name;
                        dto.Type  = entry.Id;
                        if (entry.Items != null)
                        {
                            foreach (var valuef in entry.Items)
                            {
                                var dtoi = new ProductFilterItem();
                                dtoi.Count = valuef.Count ?? 0;
                                dtoi.Id    = valuef.Id;
                                dtoi.Name  = valuef.Name;
                                dtoi.Type  = valuef.Type;
                                dtoi.Value = valuef.Value;
                                dto.Items.Add(dtoi);
                            }
                        }
                        else if (entry.FalseCount.HasValue)
                        {
                            var dtoi = new ProductFilterItem();
                            dtoi.Count = entry.Count ?? 0;
                            dtoi.Name  = "True";
                            dto.Items.Add(dtoi);

                            dtoi       = new ProductFilterItem();
                            dtoi.Count = entry.FalseCount ?? 0;
                            dtoi.Name  = "False";
                            dto.Items.Add(dtoi);
                        }
                        result.Add(dto);
                    }
                }
                else if (item.Name.Equals("ohf"))
                {
                    result.Add(dto);
                    var dtoi = new ProductFilterItem();
                    dtoi.Count = item.Items[0].Count ?? 0;
                    dtoi.Name  = "Onhand";
                    dto.Items.Add(dtoi);
                }
                else
                {
                    foreach (var entry in item.Items)
                    {
                        var dtoi = new ProductFilterItem();
                        dtoi.Count = entry.Count ?? 0;
                        dtoi.Id    = entry.Id;
                        dtoi.Name  = entry.Name;
                        dtoi.Type  = entry.Type;
                        dtoi.Value = entry.Value;
                        dto.Items.Add(dtoi);
                    }
                    result.Add(dto);
                }
            }

            return(result);
        }