public ActionResult Index(string Keywords, string sortOrder, int?page)
        {
            ViewBag.CurrentSort   = sortOrder;
            ViewBag.CurrentFilter = Keywords;

            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            var _Jobtitles = _JobTitleService.GetAll();

            switch (sortOrder)
            {
            case "name_desc":
                _Jobtitles = _Jobtitles.OrderByDescending(s => s.JobTitle1);
                break;

            default:
                _Jobtitles = _Jobtitles.OrderBy(s => s.JobTitle1);
                break;
            }
            if (!string.IsNullOrWhiteSpace(Keywords))
            {
                _Jobtitles = _Jobtitles.Where(jotitle => jotitle.JobTitle1.Contains(Keywords));
            }
            int pageSize   = 4;
            int pageNumber = (page ?? 1);

            return(View(_Jobtitles.ToPagedList(pageNumber, pageSize)));
        }
예제 #2
0
        public ActionResult Create()
        {
            var model = new EmployeeViewModel();

            model.offices   = new SelectList(_OfficeService.GetAll(), "Id", "OfficeCode");
            model.jobtitles = new SelectList(_JobTitleService.GetAll(), "Id", "JobTitle1");
            model.employees = new SelectList(_EmployeeService.GetAll(), "Id", "Firstname");
            return(View(model));
        }
예제 #3
0
        //4.1	职位管理
        //(列表(分页)、新建、编辑、删除(存在员工时不可删除)
        //):名称(不可空),备注(可空),职位需要的证照类别(多个,可空)

        public ResultMessage DoValidation(JobTitle model)
        {
            ResultMessage msg = new ResultMessage();

            if (string.IsNullOrEmpty(model.name))
            {
                msg.Success = false;
                msg.Content = "职位名称不能为空";

                return(msg);
            }

            IJobTitleService cs    = new JobTitleService(Settings.Default.db);
            List <JobTitle>  shift = cs.GetAll();

            if (model.id <= 0)
            {
                bool isRecordExists = shift.Where(p => p.name == model.name).ToList().Count() > 0;

                if (isRecordExists)
                {
                    msg.Success = false;
                    msg.Content = "数据已经存在!";

                    return(msg);
                }
            }
            else
            {
                bool isRecordExists = shift.Where(p => p.name == model.name && p.id != model.id).ToList().Count() > 0;

                if (isRecordExists)
                {
                    msg.Success = false;
                    msg.Content = "数据已经存在!";

                    return(msg);
                }
            }

            return(new ResultMessage()
            {
                Success = true, Content = ""
            });
        }
 public ActionResult <List <JobTitle> > GetAll() =>
 _jobTitleService.GetAll();