Beispiel #1
0
        public JsonResult GetBrandsAjax(long id = 0)
        {
            HomeFloorInfo homeFloor = null;
            IEnumerable <HomeFloorDetail.Brand> _Floorbrands = null;
            var brands = _iBrandService.GetBrands("");

            if (id != 0)
            {
                homeFloor    = _iFloorService.GetHomeFloor(id);
                _Floorbrands = homeFloor.FloorBrandInfo.Select(
                    item => new HomeFloorDetail.Brand()
                {
                    Id   = item.BrandId,
                    Name = item.BrandInfo.Name
                }
                    );
            }

            var data = new List <BrandViewModel>();

            foreach (var brand in brands)
            {
                data.Add(new Models.Product.BrandViewModel
                {
                    id        = brand.Id,
                    isChecked = null == _Floorbrands ? false : _Floorbrands.Any(b => b.Id.Equals(brand.Id)),
                    value     = brand.Name
                });
            }
            return(Json(new
            {
                data = data
            }, JsonRequestBehavior.AllowGet));
        }