예제 #1
0
        public int DeleteRoomByID(int?schoolID, int?roomID)
        {
            int returnCode;

            // Check if arguments are null
            if (schoolID != null && roomID != null)
            {
                // Look for school in DB
                Schools existingSchool;
                Rooms   existingRoom;
                existingSchool = SchoolUtils.LookForSchool((int)schoolID);
                existingRoom   = RoomUtils.LookForRoom((int)schoolID, (int)roomID);
                // If ID already existing => modifyname
                if (existingSchool != null && existingRoom != null)
                {
                    // Delete Roomin DB ; returnCode = 1 if operation successful in method // 0 if not
                    returnCode = RoomUtils.DeleteRoomByID((int)schoolID, (int)roomID);
                }
                else  // School not existing or Room not existing, returnCode = -1
                {
                    returnCode = -1;
                }
            }
            else
            { // Arguments not valid
                returnCode = -1;
            }
            return(returnCode);
        }
예제 #2
0
        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);
        }