예제 #1
0
        public ActionResult Grid(string search, int?page)
        {
            ViewBag.Search = search;
            ViewBag.Page   = page;

            var list = _employeesProvider.GetEmployees(search);

            int pageSize    = 14;
            int itemsToSkip = (page ?? 0) * pageSize;
            var elements    = list.Where(n => n.Course != null && n.Keeper).Skip(itemsToSkip).Take(pageSize).Select(n => new ListItemViewModel()
            {
                Id         = n.Id,
                Course     = n.Course.Name,
                Department = n.Course.Department != null ? n.Course.Department.Name : null,
                Email      = n.Email,
                FullName   = string.Format("{0} {1}", n.FirstName, n.LastName)
            });

            return(PartialView("Partials/_grid", elements));
        }
예제 #2
0
        public JsonResult DataTable(string search)
        {
            IList <Employee> list = null;
            var currrentEmployee  = _employeesProvider.GetEmployee(User.Identity.Name);

            if (currrentEmployee.Root)
            {
                list = _employeesProvider.GetEmployees(search);
            }
            else
            {
                list = _employeesProvider.GetEmployees(currrentEmployee.Course.Department.Id, search);
            }

            var results = list.Select(n => new ListItemViewModel()
            {
                Course = n.Course.Name,
                Id     = n.Id,
                Name   = n.FirstName + " " + n.LastName
            }).ToList();

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult EditCoursePartial(CourseViewModel course)
        {
            var keepers = _employeesProvider.GetEmployees(string.Empty)
                          .Where(n => n.Course.Id == course.Id)
                          .Select(n => new { Text = string.Format("{0} {1}", n.FirstName, n.LastName), Value = n.Id }).ToList();

            keepers.Insert(0, null);

            ViewBag.Keeper = keepers;

            var templates = _templatesProvider.GetAllTemplates().Select(n => new { Text = n.Name, Value = n.Id });

            ViewBag.Template       = templates;
            ViewBag.CanBeDestroyed = _courseDestructor.CanBeDestroyed(course.Id);

            return(PartialView("Partials/_course", course));
        }