private ServeRsvp NewServeRsvp(GroupServingParticipant record) { if (record.Rsvp != null && !((bool) record.Rsvp)) { return new ServeRsvp {Attending = false, RoleId = 0}; } else if (record.Rsvp != null && ((bool) record.Rsvp)) { return new ServeRsvp {Attending = (bool) record.Rsvp, RoleId = record.OpportunityId}; } return null; }
private TeamMember NewTeamMember(GroupServingParticipant record) { // new team member var member = new TeamMember { ContactId = record.ContactId, EmailAddress = record.ParticipantEmail, Index = record.RowNumber, LastName = record.ParticipantLastName, Name = record.ParticipantNickname, Participant = new Participant {ParticipantId = record.ParticipantId} }; member.Roles.Add(NewServingRole(record)); member.ServeRsvp = NewServeRsvp(record); return member; }
private ServingTeam NewServingTeam(GroupServingParticipant record) { return new ServingTeam { Index = record.RowNumber, EventId = record.EventId, EventType = record.EventType, EventTypeId = record.EventTypeId, GroupId = record.GroupId, Members = new List<TeamMember> {NewTeamMember(record)}, Name = record.GroupName, PrimaryContact = record.GroupPrimaryContactEmail, PastDeadline = (record.EventStartDateTime.AddDays(0 - record.OpportunitySignUpDeadline) < DateTime.Today), PastDeadlineMessage = record.DeadlinePassedMessage }; }
private ServingTime NewServingTime(GroupServingParticipant record) { return new ServingTime { Index = record.RowNumber, ServingTeams = new List<ServingTeam> {NewServingTeam(record)}, Time = record.EventStartDateTime.TimeOfDay.ToString() }; }
private ServeRole NewServingRole(GroupServingParticipant record) { return new ServeRole { Name = record.OpportunityTitle + " " + record.OpportunityRoleTitle, RoleId = record.OpportunityId, Room = record.Room, Minimum = record.OpportunityMinimumNeeded, Maximum = record.OpportunityMaximumNeeded, ShiftEndTime = record.OpportunityShiftEnd.FormatAsString(), ShiftStartTime = record.OpportunityShiftStart.FormatAsString() }; }
public List<GroupServingParticipant> GetServingParticipants(List<int> participants, long from, long to, int loggedInContactId) { var connection = _dbConnection; try { connection.Open(); var command = CreateSqlCommand(participants, from, to); command.Connection = connection; var reader = command.ExecuteReader(); var groupServingParticipants = new List<GroupServingParticipant>(); var rowNumber = 0; var defaultDeadlinePassedMessage = _configurationWrapper.GetConfigIntValue("DefaultDeadlinePassedMessage"); while (reader.Read()) { var rowContactId = reader.GetInt32(reader.GetOrdinal("Contact_ID")); var loggedInUser = (loggedInContactId == rowContactId); rowNumber = rowNumber + 1; var participant = new GroupServingParticipant(); participant.ContactId = rowContactId; participant.EventType = reader.GetString(reader.GetOrdinal("Event_Type")); participant.EventTypeId = reader.GetInt32(reader.GetOrdinal("Event_Type_ID")); participant.GroupRoleId = reader.GetInt32(reader.GetOrdinal("Group_Role_ID")); participant.DomainId = reader.GetInt32(reader.GetOrdinal("Domain_ID")); participant.EventId = reader.GetInt32(reader.GetOrdinal("Event_ID")); participant.EventStartDateTime = (DateTime) reader["Event_Start_Date"]; participant.EventTitle = reader.GetString(reader.GetOrdinal("Event_Title")); participant.Room = SafeString(reader, "Room"); participant.GroupId = reader.GetInt32(reader.GetOrdinal("Group_ID")); participant.GroupName = reader.GetString(reader.GetOrdinal("Group_Name")); participant.GroupPrimaryContactEmail = reader.GetString(reader.GetOrdinal("Primary_Contact_Email")); participant.OpportunityId = reader.GetInt32(reader.GetOrdinal("Opportunity_ID")); participant.OpportunityMaximumNeeded = SafeInt(reader, "Maximum_Needed"); participant.OpportunityMinimumNeeded = SafeInt(reader, "Minimum_Needed"); participant.OpportunityRoleTitle = reader.GetString(reader.GetOrdinal("Role_Title")); participant.OpportunityShiftEnd = GetTimeSpan(reader, "Shift_End"); participant.OpportunityShiftStart = GetTimeSpan(reader, "Shift_Start"); participant.OpportunitySignUpDeadline = reader.GetInt32(reader.GetOrdinal("Sign_Up_Deadline")); participant.DeadlinePassedMessage = (SafeInt32(reader, "Deadline_Passed_Message_ID") ?? defaultDeadlinePassedMessage); participant.OpportunityTitle = reader.GetString(reader.GetOrdinal("Opportunity_Title")); participant.ParticipantNickname = reader.GetString(reader.GetOrdinal("Nickname")); participant.ParticipantEmail = SafeString(reader, "Email_Address"); participant.ParticipantId = reader.GetInt32(reader.GetOrdinal("Participant_ID")); participant.ParticipantLastName = reader.GetString(reader.GetOrdinal("Last_Name")); participant.RowNumber = rowNumber; participant.Rsvp = GetRsvp(reader, "Rsvp"); participant.LoggedInUser = loggedInUser; groupServingParticipants.Add(participant); } return groupServingParticipants.OrderBy(g => g.EventStartDateTime) .ThenBy(g => g.GroupName) .ThenByDescending(g => g.LoggedInUser) .ThenBy(g => g.ParticipantNickname) .ToList(); } finally { connection.Close(); } }