Exemplo n.º 1
0
        public ActionResult _Index1(BranchSearch branchSearch, int?page)
        {
            int TotalCount      = 0;
            var pageSize        = 10;
            var pageNumber      = page ?? 1;
            int CurrentPage     = pageNumber;
            var endPage         = CurrentPage + 4;
            int PagesToShow     = 10;
            var BranchModelList = Services.BranchService.GetSearchData(branchSearch, page, out TotalCount);

            foreach (var date1 in BranchModelList)
            {
                if (date1.DateOpen != null && date1.DateClosed != null)
                {
                    var DateOpen = date1.DateOpen.Substring(0, date1.DateOpen.Length - 9);
                    date1.DateOpen = DateOpen;
                    var DateClosed = date1.DateClosed.Substring(0, date1.DateClosed.Length - 9);
                    date1.DateClosed = DateClosed;
                }
            }
            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(BranchModelList));
        }
Exemplo n.º 2
0
        public ServiceResult <List <Branch> > GetSearchData(BranchSearch branchSearch)
        {
            ServiceResult <List <Branch> > model = new ServiceResult <List <Branch> >();
            var source   = db.Branches.Where(x => x.IsActive == true);
            var pageSize = 10;

            if (branchSearch != null)
            {
                if (!string.IsNullOrEmpty(branchSearch.BranchCode))
                {
                    source = db.Branches.Where(m => m.BranchCode.Contains(branchSearch.BranchCode.ToLower()));
                }
                if (!string.IsNullOrEmpty(branchSearch.Name))
                {
                    source = db.Branches.Where(m => m.Name.Contains(branchSearch.Name.ToLower()));
                }
            }

            int count = source.Count();
            var items = source.OrderByDescending(m => m.Id).Skip(((branchSearch.Page ?? 1) - 1) * pageSize).Take(pageSize).ToList();

            model.data = items.Select(x => new Branch
            {
                Id           = x.Id,
                BranchCode   = x.BranchCode,
                AddressLine1 = x.AddressLine1,
                AddressLine2 = x.AddressLine2,
                AddressLine3 = x.AddressLine3,
                AreaCode     = x.AreaCode,
                DateClosed   = x.DateClosed,
                DateOpen     = x.DateOpen,
                IsActive     = true,
                IsClosed     = x.IsClosed,
                IsHeadOffice = x.IsHeadOffice,
                IsSendStock  = x.IsSendStock,
                LogId        = x.LogId,
                PostalCode   = x.PostalCode,
                StoreSize    = x.StoreSize,
                Telephone    = x.Telephone,
                Name         = x.Name
            }).ToList();
            model.TotalCount = count;

            return(model);;
        }
Exemplo n.º 3
0
        public List <BranchModel> GetSearchData(BranchSearch branchSearch, int?page, out int TotalCount)
        {
            // int pageSize = 10;
            int pageNumber = (page ?? 1);
            var body       = JsonConvert.SerializeObject(branchSearch);
            var result     = ServerResponse.Invoke <ServiceResult <List <BranchModel> > >("api/branch/getSearchData", body, "Post");

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