Example #1
0
        public ActionResult Edit(int id = 0)
        {
            var vm = new Models.DormApply.Edit();

            using (var db = new XkSystem.Models.DbContext())
            {
                if (id > 0)
                {
                    vm.DormApplyEdit = (from p in db.Table <Dorm.Entity.tbDormApply>()
                                        where p.Id == id
                                        select new Dto.DormApply.Edit()
                    {
                        Id = p.Id,
                        DormId = p.tbDorm.Id,
                        Remark = p.Remark
                    }).FirstOrDefault();
                }
                vm.DormList = DormController.SelectList(vm.DormApplyEdit.DormId);
            }

            return(View(vm));
        }
        public ActionResult Edit(int id = 0)
        {
            var vm = new Models.DormStudent.Edit();
            var dormStudentList = new List <Dorm.Entity.tbDormStudent>();
            var RoomList        = new List <Basis.Entity.tbRoom>();

            using (var db = new XkSystem.Models.DbContext())
            {
                if (id > 0)
                {
                    vm.DormStudentEdit = (from p in db.Table <Dorm.Entity.tbDormStudent>()
                                          where p.Id == id
                                          select new Dto.DormStudent.Edit()
                    {
                        Id = p.Id,
                        DormId = p.tbDorm.Id,
                        RoomId = p.tbRoom.Id,
                        BuildId = p.tbRoom.tbBuild.Id,
                        StudentCode = p.tbStudent.StudentCode
                    }).FirstOrDefault();
                    vm.RoomList = Basis.Controllers.RoomController.SelectList(vm.DormStudentEdit.RoomId, vm.DormStudentEdit.BuildId);
                }
                dormStudentList = db.Table <Dorm.Entity.tbDormStudent>().Include(d => d.tbRoom).ToList();
                RoomList        = db.Table <Basis.Entity.tbRoom>().ToList();
            }
            vm.BuildList = Basis.Controllers.BuildController.SelectList(vm.DormStudentEdit.BuildId);
            vm.DormList  = DormController.SelectList(vm.DormStudentEdit.DormId);
            foreach (var v in vm.RoomList)
            {
                if (dormStudentList.Where(d => d.tbRoom.Id == v.Value.ConvertToInt()).Count()
                    >= RoomList.Where(d => d.Id == v.Value.ConvertToInt()).FirstOrDefault().MaxUser)
                {
                    v.Text += "(满)";
                }
            }

            return(View(vm));
        }