Пример #1
0
        public static bool checkRequestExists(int eventID, DateTime start, DateTime end)
        {
            DAL dalDataContext = new DAL();
            List<FacilityBookingRequest> existingRequests;

            // Get all the request
            existingRequests = (from facBookings in dalDataContext.facBookReqs
                                where facBookings.EventID == eventID &&
                                facBookings.RequestStartDateTime.Date == start.Date
                                orderby facBookings.BookingTime descending
                                select facBookings).ToList<FacilityBookingRequest>();

            RequestClashingChecker checker = new RequestClashingChecker(start);

            foreach (FacilityBookingRequest request in existingRequests)
            {
                if ((request.Status == BookingStatus.Pending) || (request.Status == BookingStatus.Approved))
                    checker.SetTimeSlotTaken(request.RequestStartDateTime, request.RequestEndDateTime);
            }

            return checker.HaveClash(start, end);
        }
Пример #2
0
        public static bool ValidateProgramTime(int dayID, DateTime segmentStart,
            DateTime segmentEnd, int progID = -1)
        {
            EventDay selectedday = DayController.GetDay(dayID);

            DateTime date = selectedday.DayDate;
            DateTime start = date, end = start.AddDays(1);

            Events progEvent = EventController.GetEvent(selectedday.EventID);

            if (date.Equals(progEvent.StartDateTime.Date))
                start = progEvent.StartDateTime;
            if (date.Equals(progEvent.EndDateTime.Date))
                end = progEvent.EndDateTime;
            if (segmentStart < start)
            {
                throw new FaultException<SException>(new SException("Invalid Segment Start DateTime"),
                  new FaultReason("Event starts at " + progEvent.StartDateTime +
                      ", programme segment must start after that."));

            }
            if (segmentEnd > end)
            {
                throw new FaultException<SException>(new SException("Invalid Segment End DateTime"),
                  new FaultReason("Event ends at " + progEvent.EndDateTime +
                      ", programme segment must end before that."));

            }
            if (segmentEnd <= segmentStart)
            {
                throw new FaultException<SException>(new SException("Invalid Segment Period"),
                  new FaultReason("Programme segment's end time must be after its start time."));
            }

            DAL dalDataContext = new DAL();
            List<Program> existingPrograms;

            // Get all the programs
            existingPrograms = (from programs in dalDataContext.programs
                                where programs.DayID == dayID
                                orderby programs.StartDateTime descending
                                select programs).ToList<Program>();

            RequestClashingChecker checker = new RequestClashingChecker(segmentStart);

            foreach (Program prog in existingPrograms)
            {
                if (prog.ProgramID != progID)
                    checker.SetTimeSlotTaken(prog.StartDateTime, prog.EndDateTime);
            }

            return checker.HaveClash(segmentStart, segmentEnd);
        }