public ActionResult CreateRoom(Room Room) { if (ModelState.IsValid) { if (RoomUtils.InsertRoom(Room.Name)) { return(RedirectToAction("ListRooms")); } } return(View(Room)); }
public int InsertRoom(int?schoolID, string roomName) { int returnCode; // Check if arguments are null if (schoolID != null && roomName != null) { // Look for school in DB Schools existingSchool; existingSchool = SchoolUtils.LookForSchool((int)schoolID); // If School already existing if (existingSchool != null) { // Looking if room already exists Rooms newRoom; newRoom = RoomUtils.LookForRoom((int)schoolID, roomName); if (newRoom == null) { // Create a new Room in DB ; returnCode = 1 if operation successful in method // 0 if not returnCode = RoomUtils.InsertRoom((int)schoolID, roomName); } else { returnCode = 0; // Room already existing } } else // School not existing, returnCode = -1 { returnCode = -1; } } else { // Arguments not valid returnCode = -1; } return(returnCode); }