示例#1
0
        public void AssignRoomToDepartment(Department department, Room room)
        {
            if (department == null) throw new ArgumentNullException("department");
            if (room == null) throw new ArgumentNullException("room");

            var departmentService = new DepartmentService(Context);
            departmentService.AssignRoom(department, room);
        }
示例#2
0
        public void AssignRoomToDepartment(string departmentName, string roomName)
        {
            if (string.IsNullOrEmpty(departmentName)) throw new ArgumentNullException("department");
            if (string.IsNullOrEmpty(roomName)) throw new ArgumentNullException("roomName");

            var departmentService = new DepartmentService(Context);

            departmentService.AssignRoom(departmentName, roomName);
        }
示例#3
0
        public ActionResult Create(DepartmentsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Departments = Context.Departments.OrderBy(x => x.Name).ToList();
                return View("List", model);
            }

            var departmentService = new DepartmentService(Context);
            departmentService.Create(model.NewDepartmentName);

            return RedirectToAction("List");
        }
示例#4
0
        public ActionResult Delete(Guid id)
        {
            var department = Context.Departments.FirstOrDefault(x => x.Id == id);
            if (department == null)
            {
                return HttpNotFound();
            }

            if (department.Rooms.Any())
            {
                return HttpNotFound();
            }

            var departmentService = new DepartmentService(Context);
            departmentService.Delete(department);

            return RedirectToAction("List");
        }