Exemple #1
0
        public void CreateMeeting_WhenHostsAreDefinedAndTheyAreGroupMembers_DefinedHostsAreHostsOfMeeting()
        {
            var definedProposalMemberId = new MemberId(Guid.NewGuid());
            var meetingGroup            = CreateMeetingGroup(definedProposalMemberId);

            meetingGroup.UpdatePaymentInfo(DateTime.UtcNow.AddDays(1));
            var             hostOne = new MemberId(Guid.NewGuid());
            var             hostTwo = new MemberId(Guid.NewGuid());
            List <MemberId> hosts   = new List <MemberId>();

            hosts.Add(hostOne);
            hosts.Add(hostTwo);
            meetingGroup.JoinToGroupMember(hostOne);
            meetingGroup.JoinToGroupMember(hostTwo);

            var meeting = meetingGroup.CreateMeeting("title",
                                                     MeetingTerm.CreateNewBetweenDates(
                                                         new DateTime(2019, 1, 1, 10, 0, 0),
                                                         new DateTime(2019, 1, 1, 12, 0, 0)),
                                                     "description",
                                                     MeetingLocation.CreateNew("Name", "Address", "PostalCode", "City"),
                                                     null,
                                                     0,
                                                     Term.NoTerm,
                                                     MoneyValue.Undefined,
                                                     hosts,
                                                     definedProposalMemberId);

            var meetingAttendeeAddedEvents = AssertPublishedDomainEvents <MeetingAttendeeAddedDomainEvent>(meeting);

            Assert.That(meetingAttendeeAddedEvents.Count, Is.EqualTo(2));
            Assert.That(meetingAttendeeAddedEvents[0].AttendeeId, Is.EqualTo(hostOne));
            Assert.That(meetingAttendeeAddedEvents[0].Role, Is.EqualTo(MeetingAttendeeRole.Host));
            Assert.That(meetingAttendeeAddedEvents[1].AttendeeId, Is.EqualTo(hostTwo));
            Assert.That(meetingAttendeeAddedEvents[1].Role, Is.EqualTo(MeetingAttendeeRole.Host));
        }
Exemple #2
0
 public void Update(MeetingLocation meetingLocation)
 {
     throw new NotImplementedException();
 }
Exemple #3
0
 public int Add(MeetingLocation meetingLocation)
 {
     return(_meetingLocationRepository.Add(meetingLocation));
 }
        // decide meeting place and location based on the users that are going to attend
        // as well as the location and dates they chose

        // with this in the meeting locations we have to check if the rooms is gonna be occupied for the day
        // and if its not we have to record the unavailability
        public Tuple <Boolean, String> DecideMeeting(MeetingProposal mp)
        {
            //Identify the most popular slot
            List <Tuple <Slot, int> > popularSlots = new List <Tuple <Slot, int> >();
            List <User> lu = new List <User>();

            for (int i = 0; i < mp.getSlots().Count(); i++)
            {
                popularSlots.Add(Tuple.Create(mp.getSlots()[i], 0));
                foreach (MeetingRecord mr in mp.GetMeetingRecords())
                {
                    if (!lu.Contains(mr.GetUser()))
                    {
                        lu.Add(mr.GetUser());
                    }
                    foreach (Slot s in mr.GetSlots())
                    {
                        if (s.GetDate().Equals(mp.getSlots()[i].GetDate()) && s.GetMeetingLocation().getName().Equals(mp.getSlots()[i].GetMeetingLocation().getName()))
                        {
                            popularSlots[i] = new Tuple <Slot, int>(popularSlots[i].Item1, popularSlots[i].Item2 + 1);
                        }
                    }
                }
            }
            popularSlots.OrderBy(x => x.Item2).ToList();
            //Evaluate if Location is free
            foreach (Tuple <Slot, int> tuple in popularSlots)
            {
                MeetingLocation location = tuple.Item1.GetMeetingLocation();
                String          time     = tuple.Item1.GetDate();
                foreach (MeetingLocation ml in meetingLocations)
                {
                    foreach (MeetingRoom mr in ml.GetMeetingRooms())
                    {
                        //If meeting room is free in desired location
                        if (!mr.isBooked(time))
                        {
                            //If number of participants is equal or larger than the minimum number of participants specified in the proposal
                            if (lu.Count >= mp.getMinParticipants())
                            {
                                //If number of registered users is bigger than room capacity
                                if (lu.Count > mr.GetCapacity())
                                {
                                    //Exclude last n users
                                    int    noToExclude    = lu.Count - mr.GetCapacity();
                                    User[] usersToExclude = new User[noToExclude];
                                    for (int i = 0; i < noToExclude; i++)
                                    {
                                        usersToExclude[i] = lu.ElementAt(lu.Count - 1);
                                    }
                                    for (int i = 0; i < noToExclude; i++)
                                    {
                                        lu.RemoveAll(user => user == usersToExclude[i]);
                                        Console.WriteLine("User " + usersToExclude[i].getName() + " excluded from meeting.");
                                    }
                                }

                                //Book room on all servers
                                bookRoom(mr, time);

                                //Add users to participants list
                                foreach (IClient ic in clientsList)
                                {
                                    if (lu.Contains(ic.getUser()))
                                    {
                                        mp.addUserToMeetingParticipants(ic.getUser());
                                    }
                                }
                                return(Tuple.Create(true, "Room " + mr.GetName() + " in " + ml.getName() + " booked on " + time));
                            }
                        }
                    }
                }
            }
            return(Tuple.Create(false, ""));
        }
        private void AddMeetingLocation(string location)
        {
            MeetingLocation ml = new MeetingLocation(location);

            meetingLocations.Add(ml);
        }