public JsonResult GetAllProjects()
        {
            int    start          = Convert.ToInt32(Request["start"]);
            int    length         = Convert.ToInt32(Request["length"]);
            string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"];
            string sortDirection  = Request["order[0][dir]"];
            List <Project.Project> projectList = _projectAppService.GetAllProjectList();

            if (!string.IsNullOrEmpty(Request["columns[0][search][value]"]))
            {
                projectList = projectList.Where(x => x.ProjectCode == Request["columns[0][search][value]"]).ToList();
            }
            if (!string.IsNullOrEmpty(Request["columns[1][search][value]"]))
            {
                projectList = projectList.Where(x => x.ProjectManagerID == Request["columns[1][search][value]"]).ToList();
            }
            if (!string.IsNullOrEmpty(Request["columns[2][search][value]"]))
            {
                projectList = projectList.Where(x => x.ProductManagerID == Request["columns[2][search][value]"]).ToList();
            }
            if (!string.IsNullOrEmpty(Request["columns[3][search][value]"]))
            {
                projectList = projectList.Where(x => x.ProductLeaderID == Request["columns[3][search][value]"]).ToList();
            }
            int totalRow = projectList.Count;

            projectList = projectList.OrderBy(sortColumnName + " " + sortDirection).ToList();
            projectList = projectList.Skip(start).Take(length).ToList();
            projectList.ForEach(item => {
                if (!string.IsNullOrEmpty(item.ProjectManagerID))
                {
                    var projectManager      = _employeeAppService.GetEmployeeByCode(item.ProjectManagerID);
                    item.ProjectManagerName = projectManager.EmployeeName + "(" + projectManager.EmployeeCode + ")";
                }
                if (!string.IsNullOrEmpty(item.ProductManagerID))
                {
                    var productManager      = _employeeAppService.GetEmployeeByCode(item.ProductManagerID);
                    item.ProductManagerName = productManager.EmployeeName + "(" + productManager.EmployeeCode + ")";
                }
            });
            return(Json(new { data = projectList, draw = Request["draw"], recordsTotal = totalRow, recordsFiltered = totalRow }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public PartialViewResult EmployeeInfo()
        {
            var model = _empService.GetEmployeeByCode(Common.CommonHelper.CurrentUser);

            return(PartialView("_EmployeeInfo", model));
        }