예제 #1
0
        public ActionResult Index(Template1SearchModel model)
        {
            GetDataModel(model);

            // Get Tab ID
            int tabId = 0;

            switch (model.TransactionType)
            {
            case 0:
                tabId = 0;
                break;

            case 1:
                tabId = 1;
                break;

            case 2:
                tabId = 2;
                break;

            case 3:
                break;

            default:
                tabId = 0;
                break;
            }
            Entities.ProductCondtions e = new Entities.ProductCondtions();
            model.Mapping(model, ref e);
            var lstTemp = productService.List(e);

            // Lấy danh sách Product Follow
            int loginUser = 0;

            int.TryParse(CookieHelper.Get(AdminConfigs.COOKIES_USER_ID), out loginUser);
            if (loginUser > 0)
            {
                var productFollows = productService.ListProductFollowId(loginUser);
                if (productFollows != null && productFollows.Count > 0)
                {
                    foreach (var item in productFollows)
                    {
                        lstTemp.Where(x => x.Id == item.ProductId).Select(y => { y.IsFollow = item.IsFollow; return(y); }).ToList();
                    }
                }
            }

            int totalRecord = 0;

            if (lstTemp.Count > 0)
            {
                totalRecord = lstTemp[0].Total.Value;
                Paging(model.Page, totalRecord, model.PageSize);
            }

            ViewBag.BoxTitle    = "Danh sách nhà";
            ViewBag.ListProduct = lstTemp;
            ViewBag.TabID       = tabId;

            return(View(model));
        }
예제 #2
0
        public void GetDataModel(Template1SearchModel model)
        {
            // Lấy danh sách các kiểu nhà.
            ProductService _productService = new ProductService();

            ViewBag.ListProductType = _productService.ListProductType();

            // Lấy danh sách các tỉnh.
            PlaceService _placeService = new PlaceService();

            ViewBag.ListCity = _placeService.ListPlaceItemByParent(0);
            ViewBag.ListCity.Insert(0, new Entities.Item()
            {
                Text = "--- Chọn tỉnh ---", Id = -1
            });
            // Lấy danh sách các huyện quận theo tỉnh.
            if (model.CityId > 0)
            {
                ViewBag.ListDistrict = _placeService.ListPlaceItemByParent(model.CityId);
            }
            else
            {
                ViewBag.ListDistrict = new List <Entities.Item>();
            }
            ViewBag.ListDistrict.Insert(0, new Entities.Item()
            {
                Text = "--- Chọn quận huyện ---", Id = -1
            });

            // Lấy danh sách xã phường theo quận huyện.
            if (model.DistrictId > 0)
            {
                ViewBag.ListWard = _placeService.ListPlaceItemByParent(model.DistrictId);
            }
            else
            {
                ViewBag.ListWard = new List <Entities.Item>();
            }
            ViewBag.ListWard.Insert(0, new Entities.Item()
            {
                Text = "--- Chọn xã phường ---", Id = -1
            });

            // Lấy danh sách diện tích nhỏ nhất
            var listAreaMin = Helpers.DefaultData.ListArea();

            // Lấy danh sách diện tích nhỏ nhất
            var listAreaMax = Helpers.DefaultData.ListArea();

            listAreaMax.Add(new Entities.Item()
            {
                Id   = 100000,
                Text = ">" + listAreaMin[listAreaMin.Count - 1].Id.ToString()
            });


            if (model.MaxArea > 0)
            {
                listAreaMin = listAreaMin.Where(x => x.Id <= model.MaxArea).ToList();
            }

            if (model.MinArea > 0)
            {
                listAreaMax = listAreaMax.Where(x => x.Id >= model.MinArea).ToList();
            }


            ViewBag.ListAreaMin = listAreaMin;

            ViewBag.ListAreaMax = listAreaMax;

            model.ListUser = userService.ListItem();
        }