Exemple #1
0
        // GET: SystemMaint/Role
        public ActionResult Index(VM.RoleInfoSearch search)
        {
            SetViewBage();
            ViewBag.IsSortable = true;
            var model = new VM.RoleInfoModel();

            ViewBag.DisplayDate = BasicParam.DatetimeFormat;
            BL.RoleInfo empBL = new BL.RoleInfo();
            model.List   = empBL.GetItems(search);
            model.Search = search;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_List", model.List));
            }
            return(View(model));
        }
Exemple #2
0
        //[ChildActionOnly]
        public ActionResult GridView()
        {
            string json = Request.Params["searchModel"];

            VM.RoleInfoSearch searchModel = new VM.RoleInfoSearch();
            if (json != null)
            {
                try
                {
                    searchModel = JsonConvert.DeserializeObject(json, typeof(VM.RoleInfoSearch)) as VM.RoleInfoSearch;
                }
                catch
                {
                    return(Json("error", JsonRequestBehavior.AllowGet));
                }
            }
            BL.RoleInfo empBL = new BL.RoleInfo();
            ViewBag.DisplayDate = BasicParam.DatetimeFormat;
            var model = empBL.GetItems(searchModel);

            return(PartialView("_List", model));
        }
Exemple #3
0
        private Expression <Func <MD.tbl_Common_Role, bool> > BuildSearchCriteria(VM.RoleInfoSearch searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException("searchModel is null.");
            }

            Expression <Func <MD.tbl_Common_Role, bool> > expr    = null;
            DynamicLambda <MD.tbl_Common_Role>            builder = new DynamicLambda <MD.tbl_Common_Role>();

            if (searchModel.BeginDate.HasValue)
            {
                Expression <Func <MD.tbl_Common_Role, bool> > temp = s => s.CreatedDate >= searchModel.BeginDate;
                expr = builder.BuildQueryAnd(expr, temp);
            }
            if (searchModel.EndDate.HasValue)
            {
                Expression <Func <MD.tbl_Common_Role, bool> > temp = s => s.CreatedDate <= searchModel.EndDate;
                expr = builder.BuildQueryAnd(expr, temp);
            }

            return(expr);
        }
Exemple #4
0
        public IQueryable <VM.RoleInfoItem> GetItems(VM.RoleInfoSearch searchModel)
        {
            //Build search criteria lambda expression
            Expression <Func <MD.tbl_Common_Role, Boolean> > expr = BuildSearchCriteria(searchModel);
            //if not set the sort way ,then the default set will be used.
            string sortBy        = "RoleId";
            string sortDirection = "DESC";

            if (!string.IsNullOrWhiteSpace(searchModel.SortBy))
            {
                sortBy        = searchModel.SortBy;
                sortDirection = searchModel.SortDirection;
            }

            IQueryable <MD.tbl_Common_Role> resultQueryable;

            resultQueryable = this.Ctx.tbl_Common_Role;
            if (expr != null)
            {
                resultQueryable = resultQueryable.Where(expr).SortWith(sortBy, sortDirection).Where(m => m.IsDeleted != true);
            }
            else
            {
                resultQueryable = resultQueryable.SortWith(sortBy, sortDirection).Where(m => m.IsDeleted != true);
            }


            var result = resultQueryable.Select(a => new VM.RoleInfoItem()
            {
                RoleId      = a.RoleId,
                Name        = a.Name,
                Description = a.Description,
                CreatedDate = a.CreatedDate
            });

            return(result);
        }