Beispiel #1
0
        public RoomsWithFacilities(room r)
        {
            code         = r.code;
            buildingCode = r.buildingCode;
            roomType     = r.roomType;
            capacity     = r.capacity;

            facilities = r.facilities;
        }
        public RoomsWithFacilities(room r)
        {
            code = r.code;
            buildingCode = r.buildingCode;
            roomType = r.roomType;
            capacity = r.capacity;

            facilities = r.facilities;
        }
        private request UpdateRequestObject(RequestsWtihLinkedData rwld, request currentReq)
        {
            module selectedModule =
                (from mod in _db.modules
                 where mod.code == rwld.moduleCode
                 select mod).FirstOrDefault();

            currentReq.moduleCode = selectedModule.code;
            currentReq.module     = selectedModule;

            currentReq.priority          = rwld.priority;
            currentReq.day               = rwld.day;
            currentReq.startPeriod       = rwld.startPeriod;
            currentReq.endPeriod         = rwld.endPeriod;
            currentReq.weeks             = rwld.weeks;
            currentReq.numberOfStudents  = rwld.numberOfStudents;
            currentReq.parkPreference    = rwld.parkPreference;
            currentReq.sessionType       = rwld.sessionType;
            currentReq.numberOfRooms     = rwld.numberOfRooms;
            currentReq.otherRequirements = rwld.otherRequirements;
            currentReq.status            = rwld.status;
            currentReq.traditional       = rwld.traditional;


            foreach (var facData in rwld.facilities)
            {
                facility selectedFacility =
                    (from fac in _db.facilities
                     where fac.id == facData.id
                     select fac).FirstOrDefault();

                currentReq.facilities.Add(selectedFacility);
            }

            foreach (var roomData in rwld.roomPref)
            {
                room selectedRoom =
                    (from rm in _db.rooms
                     where rm.code == roomData.code
                     select rm).FirstOrDefault();

                currentReq.roomsPref.Add(selectedRoom);
            }



            IEnumerable <round> adHocRounds = (new SemRouController()).GetAdHocRoundSet();

            List <int> adHocRoundIDs = new List <int>();

            foreach (round rnd in adHocRounds)
            {
                adHocRoundIDs.Add(rnd.id);
            }

            if (adHocRoundIDs.IndexOf(currentReq.roundID) != -1)
            {
                currentReq.roomsAlloc.Clear();

                foreach (var roomData in rwld.roomPref)
                {
                    room selectedRoom =
                        (from rm in _db.rooms
                         where rm.code == roomData.code
                         select rm).FirstOrDefault();

                    currentReq.roomsAlloc.Add(selectedRoom);
                }
            }

            return(currentReq);
        }
        private request SetupNewRequestObject(RequestsWtihLinkedData rwld, bool current)
        {
            request newRequest = new request();

            module selectedModule =
                (from mod in _db.modules
                 where mod.code == rwld.moduleCode
                 select mod).FirstOrDefault();

            newRequest.moduleCode = selectedModule.code;
            newRequest.module     = selectedModule;

            SemRouController srAPI = new SemRouController();

            round selectedRound;

            if (current)
            {
                selectedRound = srAPI.GetLiveRound();

                newRequest.status = rwld.status;
            }
            else
            {
                selectedRound = srAPI.GetAdHocRound();

                newRequest.status = 1;
            }

            newRequest.roundID = selectedRound.id;

            newRequest.priority          = rwld.priority;
            newRequest.day               = rwld.day;
            newRequest.startPeriod       = rwld.startPeriod;
            newRequest.endPeriod         = rwld.endPeriod;
            newRequest.weeks             = rwld.weeks;
            newRequest.numberOfStudents  = rwld.numberOfStudents;
            newRequest.parkPreference    = rwld.parkPreference;
            newRequest.sessionType       = rwld.sessionType;
            newRequest.numberOfRooms     = rwld.numberOfRooms;
            newRequest.otherRequirements = rwld.otherRequirements;
            newRequest.traditional       = rwld.traditional;

            foreach (var facData in rwld.facilities)
            {
                facility selectedFacility =
                    (from fac in _db.facilities
                     where fac.id == facData.id
                     select fac).FirstOrDefault();

                newRequest.facilities.Add(selectedFacility);
            }

            foreach (var roomData in rwld.roomPref)
            {
                room selectedRoom =
                    (from rm in _db.rooms
                     where rm.code == roomData.code
                     select rm).FirstOrDefault();

                newRequest.roomsPref.Add(selectedRoom);
            }

            if (!current)
            {
                foreach (var roomData in rwld.roomPref)
                {
                    room selectedRoom =
                        (from rm in _db.rooms
                         where rm.code == roomData.code
                         select rm).FirstOrDefault();

                    newRequest.roomsAlloc.Add(selectedRoom);
                }
            }


            return(newRequest);
        }