コード例 #1
0
ファイル: IndicatorsController.cs プロジェクト: sidby/Sklad1
        public JsonResult LogSearchGridDataRequested()
        {
            // Get both the grid Model and the data Model
            // The data model in our case is an autogenerated linq2sql database based on Northwind.
            var gridModel        = new LogJqGridModel();
            var datacontextModel = new LoggingDataContext();

            // customize the default grid model with our custom settings
            LogSetupGrid(gridModel.LogGrid);

            // return the result of the DataBind method, passing the datasource as a parameter
            // jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc
            return(gridModel.LogGrid.DataBind(datacontextModel.Logs.OrderByDescending(x => x.Date)));
        }
コード例 #2
0
ファイル: IndicatorsController.cs プロジェクト: sidby/Sklad1
        public ActionResult Index()
        {
            ViewBag.Message = "Графики на Highcharts.";

            var gridModel = new LogJqGridModel();
            var grid      = gridModel.LogGrid;

            // NOTE: you need to call this method in the action that fetches the data as well,
            // so that the models match
            LogSetupGrid(grid);

            IndicatorsModel model = new IndicatorsModel()
            {
                LogGrid = gridModel
            };
            SkladDataContext context = new SkladDataContext();

            // Check permissions
            int currentUserId = WebSecurity.CurrentUserId;

            string[] roles = Roles.GetRolesForUser(WebSecurity.CurrentUserName);
            if (roles.Contains("limitedemployee"))
            {
                IQueryable <UserProfile> userProfiles = context.UserProfiles.Where(x => x.UserId == currentUserId);
                model.Employees = userProfiles;
                model.Managers  = userProfiles;
            }
            else
            {
                model.Employees = context.UserProfiles.Where(x => x.ContactTypeId == (int)EntityEnum.ContactTypeEnum.Employee);
                model.Managers  = context.UserProfiles
                                  .Where(x => x.ContactTypeId == (int)EntityEnum.ContactTypeEnum.Manager || x.ContactTypeId == (int)EntityEnum.ContactTypeEnum.Employee);
            }

            /*employee
             *
             * var result = (from u in datacontextModel.UserProfiles
             *            where u.DisplayName.ToLower().Contains(term.ToLower()) && (u.ContactTypeId ==
             *            (int)EntityEnum.ContactTypeEnum.Manager || u.ContactTypeId == (int)EntityEnum.ContactTypeEnum.Employee)
             *            select new { u.DisplayName, u.UserId }).ToList();
             */

            return(View(model));
        }