コード例 #1
0
        public ActionResult Edit(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Room.Edit();
                vm.BuildList    = BuildController.SelectList();
                vm.RoomTypeList = RoomTypeController.SelectList();

                if (id != 0)
                {
                    var tb = (from p in db.Table <Basis.Entity.tbRoom>()
                              where p.Id == id
                              select new Dto.Room.Edit
                    {
                        Id = p.Id,
                        No = p.No,
                        AttendanceMachine = p.AttendanceMachine,
                        RoomName = p.RoomName,
                        BuildId = p.tbBuild.Id,
                        RoomTypeId = p.tbRoomType.Id,
                        MaxUser = p.MaxUser
                    }).FirstOrDefault();
                    if (tb != null)
                    {
                        vm.RoomEdit = tb;
                    }
                }

                return(View(vm));
            }
        }
コード例 #2
0
        public ActionResult SelectRoom()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.Room.SelectRoom();
                vm.BuildList    = BuildController.SelectList();
                vm.RoomTypeList = RoomTypeController.SelectList();

                var tb = from p in db.Table <Basis.Entity.tbRoom>()
                         select p;

                if (string.IsNullOrEmpty(vm.SearchText) == false)
                {
                    tb = tb.Where(d => d.RoomName.Contains(vm.SearchText));
                }

                if (vm.BuildId != 0)
                {
                    tb = tb.Where(d => d.tbBuild.Id == vm.BuildId);
                }

                if (vm.RoomTypeId != 0)
                {
                    tb = tb.Where(d => d.tbRoomType.Id == vm.RoomTypeId);
                }

                vm.SelectRoomList = (from p in tb
                                     orderby p.tbBuild.No, p.tbBuild.BuildName, p.RoomName
                                     select new Dto.Room.SelectRoom
                {
                    Id = p.Id,
                    No = p.No,
                    RoomName = p.RoomName,
                    BuildName = p.tbBuild.BuildName,
                    RoomTypeName = p.tbRoomType.RoomTypeName,
                    MaxUser = p.MaxUser
                }).ToPageList(vm.Page);
                return(View(vm));
            }
        }