public ActionResult List()
        {
            var vm = new Models.DormData.List();

            vm.DormOptionList = DormOptionController.SelectList();

            using (var db = new XkSystem.Models.DbContext())
            {
                var tb = db.Table <Dorm.Entity.tbDormData>();
                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.tbStudent.StudentCode.Contains(vm.SearchText) || d.tbStudent.StudentName.Contains(vm.SearchText));
                }
                if (vm.DormOptionId > 0)
                {
                    tb = tb.Where(d => d.tbDormOption.Id == vm.DormOptionId);
                }
                vm.DormDataList = (from p in tb
                                   orderby p.No
                                   select new Dto.DormData.List()
                {
                    Id = p.Id,
                    DormOptionName = p.tbDormOption.DormOptionName,
                    DormOptionValue = p.tbDormOption.DormOptionValue,
                    InputDate = p.InputDate,
                    Sex = p.tbStudent.tbSysUser.tbSex.SexName,
                    StudentCode = p.tbStudent.StudentCode,
                    StudentName = p.tbStudent.StudentName
                }).ToPageList(vm.Page);
            }

            return(View(vm));
        }
        public ActionResult Edit(int id = 0)
        {
            var vm = new Models.DormData.Edit();

            if (id > 0)
            {
                using (var db = new XkSystem.Models.DbContext())
                {
                    vm.DormDataEdit = (from p in db.Table <Dorm.Entity.tbDormData>()
                                       where p.Id == id
                                       select new Dto.DormData.Edit()
                    {
                        Id = p.Id,
                        DormOptionId = p.tbDormOption.Id,
                        Remark = p.Remark,
                        StudentCode = p.tbStudent.StudentCode,
                        StudentName = p.tbStudent.StudentName
                    }).FirstOrDefault();
                }
            }
            vm.DormOptionList = DormOptionController.SelectList(vm.DormDataEdit.DormOptionId);

            return(View(vm));
        }