Ejemplo n.º 1
0
        public PageListResultBO <DM_DulieuDanhmucDTO> GetDataByPage(long danhMucId, DM_DulieuDanhmucSearchDTO searchParams, int pageIndex = 1, int pageSize = 20)
        {
            var query = (from dulieuDanhmuc in this._dM_DulieuDanhmucRepository.GetAllAsQueryable()
                         where dulieuDanhmuc.GroupId == danhMucId
                         select new DM_DulieuDanhmucDTO()
            {
                Id = dulieuDanhmuc.Id,
                Code = dulieuDanhmuc.Code,
                Name = dulieuDanhmuc.Name,
                Note = dulieuDanhmuc.Note,
                Priority = dulieuDanhmuc.Priority
            });

            if (searchParams != null)
            {
                if (!string.IsNullOrEmpty(searchParams.sortQuery))
                {
                    query = query.OrderBy(searchParams.sortQuery);
                }
                else
                {
                    query = query.OrderByDescending(x => x.Id);
                }
                if (!String.IsNullOrEmpty(searchParams.QueryCode))
                {
                    query = query.Where(x => x.Code.Contains(searchParams.QueryCode));
                }
                if (!String.IsNullOrEmpty(searchParams.QueryName))
                {
                    query = query.Where(x => x.Name.Contains(searchParams.QueryName));
                }
            }
            else
            {
                query = query.OrderByDescending(x => x.Id);
            }

            var result = new PageListResultBO <DM_DulieuDanhmucDTO>();

            if (pageSize == -1)
            {
                var pagedList = query.ToList();
                result.Count     = pagedList.Count;
                result.TotalPage = 1;
                result.ListItem  = pagedList;
            }
            else
            {
                var dataPageList = query.ToPagedList(pageIndex, pageSize);
                result.Count     = dataPageList.TotalItemCount;
                result.TotalPage = dataPageList.PageCount;
                result.ListItem  = dataPageList.ToList();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public JsonResult SearchData(FormCollection form)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as DM_DulieuDanhmucSearchDTO;

            if (searchModel == null)
            {
                searchModel          = new DM_DulieuDanhmucSearchDTO();
                searchModel.pageSize = 20;
            }

            searchModel.QueryName = form["QueryName"];
            searchModel.QueryCode = form["QueryCode"].ToUpper();
            SessionManager.SetValue(SessionSearchString, searchModel);
            var data = _dm_DulieuDanhmucService.GetDataByPage(searchModel.GroupId.GetValueOrDefault(), searchModel, 1, searchModel.pageSize);

            return(Json(data));
        }
Ejemplo n.º 3
0
        public ActionResult Index(long id)
        {
            var searchModel = new DM_DulieuDanhmucSearchDTO();

            SessionManager.SetValue(SessionSearchString, null);

            var groupName = _dm_NhomDanhmucService.GetById(id).GroupName;

            if (groupName == null)
            {
                return(HttpNotFound());
            }
            var model = new IndexVM();

            model.GroupId       = id;
            searchModel.GroupId = id;
            model.Data          = _dm_DulieuDanhmucService.GetDataByPage(id, null);
            ViewBag.PageName    = "Danh sách dữ liệu danh mục " + groupName;
            return(View("Index", model));
        }
Ejemplo n.º 4
0
        public JsonResult GetData(long groupid, int indexPage, string sortQuery, int pageSize)
        {
            var searchModel = SessionManager.GetValue(SessionSearchString) as DM_DulieuDanhmucSearchDTO;

            if (searchModel == null)
            {
                searchModel = new DM_DulieuDanhmucSearchDTO();
            }
            if (!string.IsNullOrEmpty(sortQuery))
            {
                searchModel.sortQuery = sortQuery;
            }
            if (pageSize > 0)
            {
                searchModel.pageSize = pageSize;
            }
            SessionManager.SetValue(SessionSearchString, searchModel);
            var data = _dm_DulieuDanhmucService.GetDataByPage(groupid, searchModel, indexPage, pageSize);

            return(Json(data));
        }