Ejemplo n.º 1
0
        public Appointment NewAppointment(AppointmentColumn column, string id, DateTime startTime, DateTime endTime, string subject, string locationPart1, string locationPart2, string notes, Color color, object userObject)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            var appointment = new Appointment {
                ID            = id,
                StartTime     = startTime,
                EndTime       = endTime,
                Subject       = subject,
                LocationPart1 = locationPart1,
                LocationPart2 = locationPart2,
                Notes         = notes,
                Color         = color,
                UserObject    = userObject
            };

            if (column is UnallocatedColumn)
            {
                _unallocatedAppointments.Add(appointment);
            }
            else
            {
                CheckColumnExists(column);
                _appointmentBook[column].Add(appointment);
            }
            return(appointment);
        }
Ejemplo n.º 2
0
 void CheckColumnExists(AppointmentColumn column)
 {
     if (!_appointmentBook.ContainsKey(column))
     {
         throw new SoftwareException("Column '{0}' does not exist", column.Name);
     }
 }
Ejemplo n.º 3
0
        public virtual void Reschedule(Appointment appointment, AppointmentColumn sourceColumn, AppointmentColumn destColumn, DateTime newStartTime, DateTime newEndTime)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }
            if (sourceColumn == null)
            {
                throw new ArgumentNullException("sourceColumn");
            }
            if (destColumn == null)
            {
                throw new ArgumentNullException("destColumn");
            }

            var sourceColumnIsUnallocated = sourceColumn is UnallocatedColumn;
            var destColumnIsUnallocated   = destColumn is UnallocatedColumn;

            // Moved columns:
            //	Column to Column
            //	Column to UnallocatedColumn
            //	UnallocatedColumn to Column

            if (sourceColumnIsUnallocated && destColumnIsUnallocated)
            {
                // do nothing
            }
            else if (!sourceColumnIsUnallocated && !destColumnIsUnallocated)
            {
                if (sourceColumn != destColumn)
                {
                    // Column to Column
                    CheckColumnExists(sourceColumn);
                    CheckColumnExists(destColumn);
                    _appointmentBook[sourceColumn].Remove(appointment);
                    _appointmentBook[destColumn].Add(appointment);
                }
            }
            else if (!sourceColumnIsUnallocated)
            {
                //	Column to UnallocatedColumn
                CheckColumnExists(sourceColumn);
                _appointmentBook[sourceColumn].Remove(appointment);
                _unallocatedAppointments.Add(appointment);
            }
            else
            {
                //	UnallocatedColumn to Column
                CheckColumnExists(destColumn);
                _unallocatedAppointments.Remove(appointment);
                _appointmentBook[destColumn].Add(appointment);
            }

            appointment.StartTime = newStartTime;
            appointment.EndTime   = newEndTime;
        }
Ejemplo n.º 4
0
        public virtual AppointmentColumn NewColumn(string name, object userObject)
        {
            var column = new AppointmentColumn {
                Name       = name,
                UserObject = userObject
            };

            _appointmentBook.Add(column, new List <Appointment>());
            return(column);
        }
Ejemplo n.º 5
0
        public bool IsTimeAvailable(AppointmentColumn column, Appointment appointment, DateTime startTime, DateTime endTime)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            CheckColumnExists(column);
            var overlappingAppointments =
                _appointmentBook[column]
                .Where(a => startTime <a.EndTime && endTime> a.StartTime)
                .Except(appointment);

            return(!overlappingAppointments.Any());
        }
Ejemplo n.º 6
0
        public IEnumerable <Appointment> GetAppointments(AppointmentColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            if (column is UnallocatedColumn)
            {
                return(_unallocatedAppointments);
            }
            else
            {
                CheckColumnExists(column);
                return(_appointmentBook[column]);
            }
        }
Ejemplo n.º 7
0
        public virtual void DeleteAppointment(AppointmentColumn column, Appointment appointment)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            if (column is UnallocatedColumn)
            {
                _unallocatedAppointments.Remove(appointment);
            }
            else
            {
                CheckColumnExists(column);
                _appointmentBook[column].Remove(appointment);
            }
        }