Exemple #1
0
        private List <ClassTime> CreateSchedule(IUpdateGroupClass request, int numberOfClasses, DateTime startDate, int duration)
        {
            var numberOfWeeks           = numberOfClasses / request.DayOfWeeks.Count;
            List <ClassTime> classTimes = new List <ClassTime>();
            int numberOfClass           = 1;

            for (int i = 0; i < numberOfWeeks; i++)
            {
                foreach (ClassDayOfWeekDto requestDayOfWeek in request.DayOfWeeks)
                {
                    DateTime nextDayOfWeeks = FindNearestOfDayOfWeek(startDate, requestDayOfWeek);
                    nextDayOfWeeks = nextDayOfWeeks.Add(requestDayOfWeek.BeginTime).AddMinutes(request.UtcOffsetInMinutes);

                    ClassTime classTime = ClassTimeAggregate.New()
                                          .FromGroupClass(State)
                                          .WithNumberOfClass(numberOfClass++)
                                          .WithNumberOfClasses(numberOfClasses)
                                          .AddParticipant(State.Participants.Select(x => x.User).ToList(), PresenceType.None)
                                          .WithDate(nextDayOfWeeks, duration).State;

                    classTimes.Add(classTime);
                }

                startDate = startDate.AddDays(7);
            }

            return(classTimes);
        }
Exemple #2
0
        public GroupClassAggregate RemoveParticipant(string userId)
        {
            var participantRelation = State.Participants.First(x => x.UserId == userId);

            State.Participants.Remove(participantRelation);
            State.Schedule.ForEach(x => { ClassTimeAggregate.FromState(x).RemoveParticipant(userId); });
            return(this);
        }
Exemple #3
0
        public GroupClassAggregate AddParticipantToPresenceList(User participant, PresenceType presenceType)
        {
            State.Schedule.ForEach(x =>
            {
                ClassTimeAggregate.FromState(x).AddParticipant(participant, presenceType);
            });

            return(this);
        }