public Meeting CreateMeeting(int meetingDescriptionId, DateTime meetingDate, int congregationId) { Meeting meeting = new Meeting(); meeting.MeetingDate = meetingDate; meeting.MeetingDescriptionId = meetingDescriptionId; meeting.CongregationId = congregationId; meeting.CreateDate = DateTime.Now; repository.Meetings.Add(meeting); repository.SaveChanges(); return meeting; }
public DataGridView Schedule(DataGridView data, ScheduleDate sd) { data.Rows.Clear(); data.Refresh(); List<MeetingAssignment> ma = new List<MeetingAssignment>(); if (sd == null) { return null; } else if(manager.MeetingAssignmentsForExistingSchedule(sd.Id).Count!=0) { ma = manager.MeetingAssignmentsForExistingSchedule(sd.Id); } else { ma = manager.MeetingAssignmentsForSchedule(sd, sd.CongregationId); } ma = ma.OrderBy(o => o.Meeting.MeetingDate).ThenBy(y => y.Assignment.PositionOnSchedule).ToList(); data.ColumnCount = ma[0].Meeting.MeetingAssignments.Count + 2; data.RowHeadersVisible = false; data.Columns[0].Name = "MeetingId"; data.Columns[0].Visible = false; data.Columns[1].Name = "MeetingDate"; data.Columns[1].HeaderText = "Meeting Date"; data.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; List<MeetingAssignment> test = ma[0].Meeting.MeetingAssignments.ToList(); test = test.OrderBy(o => o.Assignment.PositionOnSchedule).ToList(); int columnCounter = test.Count + 1; int assignmentcounter = test.Count - 1; while (assignmentcounter >= 0) { data.Columns[columnCounter].Name = test[assignmentcounter].Assignment.Label; data.Columns[columnCounter].HeaderText = data.Columns[columnCounter].Name; data.Columns[columnCounter].SortMode = DataGridViewColumnSortMode.NotSortable; if(columnCounter == test.Count + 1) { data.Columns[columnCounter].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } columnCounter--; assignmentcounter--; } List<Meeting> meetings = (from meet in ma select meet.Meeting).ToList(); meetings = meetings.Select(z => z).Distinct().ToList(); List<UnavailableDate> cancelled = manager.UnavailableDateByCongregationId(sd.CongregationId); cancelled = cancelled.Where(z => z.DateUnavailable > sd.StartDate && z.DateUnavailable < sd.EndDate).ToList(); if(cancelled.Count!=0) { foreach(UnavailableDate u in cancelled) { Meeting nm = new Meeting(); nm.MeetingDate = u.DateUnavailable; meetings.Add(nm); } } meetings = meetings.OrderBy(o => o.MeetingDate).ToList(); int rowCounter = 0; foreach (Meeting meet in meetings) { data.Rows.Add(); data.Rows[rowCounter].Cells[0].Value = meet.Id; data.Rows[rowCounter].Cells[1].Value = meet.MeetingDate.DayOfWeek + " " + meet.MeetingDate.ToString("MMM") + " " + meet.MeetingDate.Day; List<MeetingAssignment> cahi = manager.MeetingAssignmentsByMeetingId(meet.Id); if(cahi.Count==0) { rowCounter++; continue; } cahi.OrderBy(o => o.Assignment.PositionOnSchedule).ToList(); int CellCounter = 2; foreach (MeetingAssignment am in cahi) { data.Rows[rowCounter].Cells[CellCounter].Value = ((am.Member.PreferredName) ?? am.Member.FirstName + " " + am.Member.LastName); CellCounter++; } rowCounter++; } return data; }
public Member NextMemberToAssign(List<Member> membersAvailable, Meeting currentMeeting, Assignment currentAssignment) { List<Member> newMembers = (from mem in membersAvailable where mem.MeetingAssignments.Count == 0 select mem).ToList(); if (newMembers.Count != 0) { newMembers = newMembers.OrderBy(z => z.FirstName).ToList(); return newMembers[0]; } int meetingCountToBeat = new int(); int meetingCounter = 0; Member currentlySelected = new Member(); MeetingAssignment mLastMeetingAssignment = new MeetingAssignment(); List<Member> alreadyAssigned = (from l in currentMeeting.MeetingAssignments select l.Member).ToList(); List<Meeting> allMeeting = (from v in repository.Meetings where v.CongregationId == currentMeeting.CongregationId select v).ToList(); allMeeting = allMeeting.OrderByDescending(o => o.MeetingDate).ToList(); int index = allMeeting.IndexOf(currentMeeting); List<Member> go = (from goat in allMeeting[index + 1].MeetingAssignments select goat.Member).ToList(); foreach (Member m in membersAvailable) { List<MeetingAssignment> selectedMAssignments = (from d in repository.MeetingAssignments where d.MemberId == m.Id select d).ToList(); selectedMAssignments = selectedMAssignments.OrderByDescending(o => o.Meeting.MeetingDate).ToList(); if (alreadyAssigned.Any(p => p.Id == m.Id))//skips if they are already assigned or previous assignment was same assignment. { continue; } if (selectedMAssignments[0].AssignmentId == currentAssignment.Id && m.MemberAssignments.Count > 2) { continue; } foreach (DateTime d in EachDayLoop(selectedMAssignments[0].Meeting.MeetingDate.AddDays(1), currentMeeting.MeetingDate.AddDays(-1))) { if (Convert.ToString(d.DayOfWeek) == m.Congregation.PublicMeetingDay || Convert.ToString(d.DayOfWeek) == m.Congregation.WeekMeetingDay) { meetingCounter++; } } if (currentlySelected.Id == 0) { meetingCountToBeat = meetingCounter; currentlySelected = m; mLastMeetingAssignment = selectedMAssignments[0]; meetingCounter = 0; continue; } if (meetingCounter > meetingCountToBeat) { meetingCountToBeat = meetingCounter; currentlySelected = m; mLastMeetingAssignment = selectedMAssignments[0]; meetingCounter = 0; } if (meetingCounter == meetingCountToBeat) { if (selectedMAssignments[0].Assignment.Label != currentAssignment.Label && mLastMeetingAssignment.Assignment.Label == currentAssignment.Label) { currentlySelected = m; mLastMeetingAssignment = selectedMAssignments[0]; } } meetingCounter = 0; continue; } return currentlySelected; }
public Task <IEnumerable <MeetingTimeCandidate> > FindMeetingTimes(Meeting meeting) { throw new NotImplementedException(); }
public async Task <Meeting> UpdateEvent(Meeting meeting) { string uri = EventsFolder + meeting.Id; return(await GetHttpHelper().PatchItemAsync <Meeting>(uri, meeting)); }
public async Task <Meeting> CreateEvent(Meeting meeting) { string uri = EventsFolder; return(await GetHttpHelper().PostItemAsync <Meeting>(uri, meeting)); }
private void BuildFilter(StringBuilder sb, Meeting meeting) { sb.AppendFormat("Subject eq '{0}'", meeting.Subject); AddTimeStamp(sb, meeting); }
private MeetingTimes BuildRequestBody(Meeting meeting) { var result = new MeetingTimes { MeetingDuration = "PT30M", Attendees = new List <MeetingTimes.Attendee>(), TimeConstraint = new TimeConstraint { Timeslots = new List <MeetingTimeSlot>() }, LocationConstraint = new LocationConstraint() { IsRequired = false, Locations = new List <Location>() }, MaxCandidates = 20, }; foreach (var a in meeting.Attendees ?? Enumerable.Empty <Attendee>()) { if (meeting.Organizer == null || !a.EmailAddress.IsEqualTo(meeting.Organizer.EmailAddress)) { result.Attendees.Add(new MeetingTimes.Attendee { EmailAddress = a.EmailAddress }); } } var date = meeting.Start.DateTime; // From 8AM to 6PM local time var start = new DateTime(date.Year, date.Month, date.Day, 8, 0, 0, DateTimeKind.Local); var end = new DateTime(date.Year, date.Month, date.Day, 18, 0, 0, DateTimeKind.Local); start = start.ToUniversalTime(); end = end.ToUniversalTime(); var timeSlot = new MeetingTimeSlot { Start = new MeetingTimeSlot.TimeDescriptor { Date = start.DateToApiString(), Time = start.TimeOfDay.ToString(), TimeZone = "UTC" }, End = new MeetingTimeSlot.TimeDescriptor { Date = end.DateToApiString(), Time = end.TimeOfDay.ToString(), TimeZone = "UTC" } }; result.TimeConstraint.Timeslots.Add(timeSlot); if (!string.IsNullOrEmpty(meeting.Location.DisplayName)) { result.LocationConstraint.Locations.Add(new Location { DisplayName = meeting.Location.DisplayName }); } return(result); }