I have some questions here. This is the code which displayed all the meeting details. and now i would like to add one more condition, which is where ar.Response == "ConfirmedAtVenue" this response attribute will be stored in AttendeeResponse table. and i could not make it work, i always get an error or null exception . I had tried to put in the last row or even after the join j2, but still not working.
private MeetingIndexViewmodel GetMeetingDetailsForIndexView(int id)
{
//Names
string AttendeeNameMatch = GetAttendeeName(id);
string ConvenerNameMatch = GetConvenerName(id);
string OrganiserNameMatch = GetOrganiserName(id);
//Telephone Numbers
int AttendeeTelNoMatch = GetAttendeeTelNo(id);
int ConvenerTelNoMatch = GetConvenerTelNo(id);
int OrganiserTelNoMatch = GetOrganiserTelNo(id);
//Email
string AttendeeEmailMatch = GetAttendeeEmail(id);
string ConvenerEmailMatch = GetConvenerEmail(id);
string OrganiserEmailMatch = GetOrganiserEmail(id);
var meetingDetails = (from p in db.Persons
join ts in db.Timeslots on p.PersonID equals ts.PersonID into j1
from ts in j1.DefaultIfEmpty()
join ar in db.AttendeeResponses on ts.TimeslotID equals ar.TimeslotID into j2
from ar in j2.DefaultIfEmpty()
join pm in db.PersonMeetings on ar.PersonMeetingID equals pm.PersonMeetingID into j3
from pm in j3.DefaultIfEmpty()
join m in db.Meetings on pm.MeetingID equals m.MeetingID into j4
from i in j4.DefaultIfEmpty()
where i.MeetingID == id && pm.MeetingRole.Equals("Attendee") //&& ar.Response.Equals("NoResponse")
//The above two lines were needed for the null MeetingIDs to be reported
select new MeetingIndexViewmodel
{
MeetingID = id,
AttendeeName = AttendeeNameMatch,
ConvenerName = ConvenerNameMatch,
OrganiserName = OrganiserNameMatch,
StartTime = ts.StartTime.ToString() ?? "null",
Duration = ts.Duration.ToString() ?? "null",
AttendeeResponseID = ar.AttendeeResponseID,
Response = ar.Response,
}
).FirstOrDefault();
return meetingDetails;
}