public void UnbanRoom(Room room)
        {
            using (var context = NewContext())
            {
                var r = context.Rooms.SingleOrDefault(x => x.Id == room.Id);
                r.Allowed = true;

                context.SubmitChanges();
            }
        }
        public void AttachComputerToRoom(Computer computer, Room room)
        {
            using (var context = NewContext())
            {
                computer.Room = room;
                context.Computers.Attach(computer, true);

                context.SubmitChanges();
            }
        }
        public void BanRoom(Room room)
        {
            using (var context = NewContext())
            {
                var r = context.Rooms.SingleOrDefault(x => x.Id == room.Id);
                r.Allowed = false;

                foreach (Computer comp in r.Computers)
                    comp.Banned = true;
                    
                context.SubmitChanges();
            }
        }
Exemple #4
0
        public ActionResult AddRoom(AddRoomViewModel viewModel)
        {
            if (!String.IsNullOrEmpty(viewModel.Name))
            {
                var newRoom = new Room
                {
                    Name = viewModel.Name,
                    Allowed = viewModel.Allowed
                };

                _BanStorage.CreateRoom(newRoom);
            }
            return View(viewModel);
        }
Exemple #5
0
        public ActionResult EditRoom(RoomsViewModel Model)
        {
            var room = new Room();
            room = _BanStorage.GetRoom(Model.CurrentRoom);
            foreach(String comp in Model.Computers)
            {
                var computer = _BanStorage.GetComputer(comp);
                if (computer.Room == null)
                    _BanStorage.AttachComputerToRoom(computer, room);
            }

            foreach (String comp in Model.UnchoosenComputers)
            {
                var computer = _BanStorage.GetComputer(comp);
                if (computer.Room != null)
                    _BanStorage.DetachComputer(computer);
            }
            return View(Model);
        }
        public void DeleteRoom(Room room)
        {
            using (var context = NewContext())
            {
                context.Computers.Attach(room, true);
                context.Computers.DeleteOnSubmit(room);

                context.SubmitChanges();
            }
        }
 public void CreateRoom(Room room)
 {
     using (var context = NewContext())
     {
         context.Rooms.InsertOnSubmit(room);
         context.SubmitChanges();
     }
 }
 partial void DeleteRoom(Room instance);
 partial void UpdateRoom(Room instance);
 partial void InsertRoom(Room instance);