public static AppointmentDetails FromAppointment(Appointment appointment, int currentUserId, List <User> allParticipants) { IEnumerable <AppointmentParticipationInformation> withAnswers = appointment.AppointmentParticipations.Select(p => new AppointmentParticipationInformation(p.Participant.FullName, p.Participant.Id, p.AppointmentParticipationAnswer)); IEnumerable <User> otherParticipants = allParticipants.Except(appointment.AppointmentParticipations.Select(a => a.Participant)); IEnumerable <AppointmentParticipationInformation> noAnswers = otherParticipants.Select(p => new AppointmentParticipationInformation(p.FullName, p.Id, null)); List <AppointmentParticipationInformation> participations = withAnswers.Concat(noAnswers).ToList(); AppointmentInformation appointmentInformation = AppointmentInformation.FromAppointment(appointment, currentUserId, allParticipants.Count); return(new AppointmentDetails(appointmentInformation, participations)); }
public static AppointmentInformation FromAppointment(Appointment appointment, int currentUserId, int totalCount) { int acceptedCount = appointment.AppointmentParticipations.Count(a => a.AppointmentParticipationAnswer == AppointmentParticipationAnswer.Accepted); int declinedCount = appointment.AppointmentParticipations.Count(a => a.AppointmentParticipationAnswer == AppointmentParticipationAnswer.Declined); int noAnswerCount = totalCount - (acceptedCount + declinedCount); AppointmentParticipationAnswer?currentUserAnswer = appointment.AppointmentParticipations.FirstOrDefault(a => a.ParticipantId == currentUserId)?.AppointmentParticipationAnswer; var appointmentInformation = new AppointmentInformation(appointment.Id, appointment.StartTime, currentUserAnswer, acceptedCount, declinedCount, noAnswerCount); return(appointmentInformation); }
public static EventOverviewInformation FromEvent(Event @event, Appointment firstUpcomingAppointment, int currentUserId) { ViewEventInformation viewEventInformation = ViewEventInformation.FromEvent(@event, currentUserId); if (firstUpcomingAppointment == null) { return(new EventOverviewInformation(@event.Id, viewEventInformation, null)); } AppointmentInformation appointmentInformation = AppointmentInformation.FromAppointment(firstUpcomingAppointment, currentUserId, @event.EventParticipations.Count); return(new EventOverviewInformation(@event.Id, viewEventInformation, appointmentInformation)); }
public EventOverviewInformation(int eventId, ViewEventInformation viewEventInformation, AppointmentInformation latestAppointmentInformation) { EventId = eventId; ViewEventInformation = viewEventInformation; LatestAppointmentInformation = latestAppointmentInformation; }
public AppointmentDetails(AppointmentInformation appointmentInformation, List <AppointmentParticipationInformation> participations) { AppointmentInformation = appointmentInformation; Participations = participations; }