// TODO: Document
        /// <summary>
        ///
        /// </summary>
        /// <param name="sessions"></param>
        public static void Validate(this IEnumerable <Entities.Session> sessions)
        {
            if (sessions == null)
            {
                throw new ArgumentNullException(nameof(sessions));
            }

            if (sessions.Count() == 0)
            {
                throw new ArgumentException("You must have at least one session");
            }

            if (sessions.Select(s => s.Id).Distinct().Count() != sessions.Count())
            {
                throw new ArgumentException("Session Ids must be unique");
            }

            if (sessions.Count(s => s.Presenters == null || s.Presenters.Count() < 1) > 0)
            {
                throw new ArgumentException("Every session must have at least one presenter.");
            }

            var presentations = new SessionsCollection(sessions);

            if (presentations.HaveCircularDependencies())
            {
                throw new DependencyException("Sessions may not have circular dependencies.");
            }

            VerifyPresenterAvailabilities(sessions);
        }
Exemplo n.º 2
0
        private static void Validate(IEnumerable <Session> sessions, IEnumerable <Room> rooms, IEnumerable <Timeslot> timeslots)
        {
            if (sessions == null)
            {
                throw new ArgumentNullException(nameof(sessions));
            }

            if (rooms == null)
            {
                throw new ArgumentNullException(nameof(rooms));
            }

            if (timeslots == null)
            {
                throw new ArgumentNullException(nameof(timeslots));
            }

            if (sessions.Count() == 0)
            {
                throw new ArgumentException("You must have at least one session");
            }

            if (timeslots.Count() == 0)
            {
                throw new ArgumentException("You must have at least one timeslot");
            }

            if (rooms.Count() == 0)
            {
                throw new ArgumentException("You must have at least one room");
            }

            if (sessions.Count(s => s.Presenters == null || s.Presenters.Count() < 1) > 0)
            {
                throw new ArgumentException("Every session must have at least one presenter.");
            }

            var presentations = new SessionsCollection(sessions);

            if (presentations.HaveCircularDependencies())
            {
                throw new DependencyException("Sessions may not have circular dependencies.");
            }
        }
Exemplo n.º 3
0
        private static void Validate(IEnumerable<Session> sessions, IEnumerable<Room> rooms, IEnumerable<Timeslot> timeslots)
        {
            if (sessions == null)
                throw new ArgumentNullException(nameof(sessions));

            if (rooms == null)
                throw new ArgumentNullException(nameof(rooms));

            if (timeslots == null)
                throw new ArgumentNullException(nameof(timeslots));

            if (timeslots.Count() == 0)
                throw new ArgumentException("You must have at least one timeslot");

            if (sessions.Count() == 0)
                throw new ArgumentException("You must have at least one session");

            if (rooms.Count() == 0)
                throw new ArgumentException("You must have at least one room");

            if (sessions.Count(s => s.Presenters == null || s.Presenters.Count() < 1) > 0)
                throw new ArgumentException("Every session must have at least one presenter.");

            var presentations = new SessionsCollection(sessions);
            if (presentations.HaveCircularDependencies())
                throw new Exceptions.DependencyException("Sessions may not have circular dependencies.");
        }