示例#1
0
        public ActionResult _Index1(ColorSearch colorSearch, int?page)
        {
            int TotalCount     = 0;
            var pageSize       = 10;
            var pageNumber     = page ?? 1;
            int CurrentPage    = pageNumber;
            var endPage        = CurrentPage + 4;
            int PagesToShow    = 10;
            var body           = JsonConvert.SerializeObject(colorSearch);
            var ColorModelList = Services.ColorService.GetSearchData(colorSearch, page, out TotalCount);

            ViewBag.TotalCount = TotalCount;
            ViewBag.PageSize   = pageSize;
            var result     = Helper.CommonFunction.GetPages(TotalCount, pageSize, CurrentPage, PagesToShow);
            int totalPages = (TotalCount / pageSize) + (TotalCount % pageSize == 0 ? 0 : 1);

            ViewBag.result      = result;
            ViewBag.totalPages  = totalPages;
            ViewBag.CurrentPage = CurrentPage;
            var pageCount = result.Count();

            ViewBag.pageCount = pageCount;

            ViewBag.endPage = endPage;
            return(View(ColorModelList));
        }
示例#2
0
        public ServiceResult <List <Color> > GetSearchData(ColorSearch colorSearch)
        {
            ServiceResult <List <Color> > model = new ServiceResult <List <Color> >();
            var source   = Entities.Colors.Where(x => x.IsActive == true);
            var pageSize = 10;

            if (colorSearch != null)
            {
                if (!string.IsNullOrEmpty(colorSearch.Code) || !string.IsNullOrEmpty(colorSearch.ColorLong) || !string.IsNullOrEmpty(colorSearch.ColorShort) || !string.IsNullOrEmpty(colorSearch.iCode))
                {
                    source = source.Where(m => m.Code == colorSearch.Code || m.ColorLong == colorSearch.ColorLong || m.ColorShort == colorSearch.ColorShort || m.Code == colorSearch.iCode);
                }
            }
            int count = source.Count();
            var items = source.OrderByDescending(m => m.Id).Skip(((colorSearch.Page ?? 1) - 1) * pageSize).Take(pageSize).ToList();

            model.data = items.Select(x => new Color
            {
                Id         = x.Id,
                Code       = x.Code,
                ColorLong  = x.ColorLong,
                ColorShort = x.ColorShort,
                IsActive   = x.IsActive
            }).ToList();
            model.TotalCount = count;
            return(model);;
        }
示例#3
0
        public List <ColorModel> GetSearchData(ColorSearch colorSearch, int?page, out int TotalCount)
        {
            //  int pageSize = 10;
            int pageNumber = (page ?? 1);
            var body       = JsonConvert.SerializeObject(colorSearch);
            var result     = ServerResponse.Invoke <ServiceResult <List <ColorModel> > >("api/color/getSearchData", body, "Post");

            TotalCount = result.TotalCount;
            if (result.data != null)
            {
                var model = result.data.ToList();
                return(model);
            }
            else
            {
            }
            return(result.data.ToList());
        }