/// <summary> /// Create and return the TimeSlot object from passed tbl_TimeSlot /// </summary> /// <param name="tSlot"></param> /// <returns></returns> private TimeSlot GetTimeSlotDetails(tbl_TimeSlot tSlot) { var context = new dbDataContext(); var timeSlot = new TimeSlot { TimeSlotId = tSlot.TimeSlotId, InterviewId = tSlot.InterviewId, SlotDate = Convert.ToDateTime(tSlot.InterviewDate).ToShortDateString(), SlotTime = Convert.ToDateTime(tSlot.InterviewDate).ToString("HH:mm"), Duration = tSlot.Duration, CreatedDate = tSlot.CreatedDate, LastUpdatedDate = Convert.ToDateTime(tSlot.LastUpdatedDate) }; if (tSlot.LocationId > 0) timeSlot.Location = GetInterviewLocation(tSlot.LocationId); //contact timeSlot.AllocatedContact = null; if (tSlot.InterviewRequestId > 0) { // get the request detail var request = context.tbl_InterviewRequests.FirstOrDefault(t => t.InterviewRequestId == tSlot.InterviewRequestId); if (request != null) { // get the contact var contact = context.tbl_Candidates.FirstOrDefault(t => t.CandidateId == request.CandidateId); if (contact != null) { timeSlot.AllocatedContact = new TimeSlotContact { ContactId = contact.CandidateId, FullName = contact.Forename + " " + contact.Surname }; } } } //interviewers var interviewers = new List<Interviewer>(); var qInterviewers = (context.tbl_TimeSlotInterviewers.Where(x => x.TimeSlotId == tSlot.TimeSlotId)); foreach (var i in qInterviewers) { if (i.IsUser) { //this is a user interviewers.Add((context.tbl_Users.Where(x => x.UserId == i.InterviewerId).Select(x => new Interviewer { Forename = x.Forename, Surname = x.Surname, Email = x.Email, Id = x.UserId, IsUser = true }).FirstOrDefault())); } else { //get from interviewer table interviewers.Add((context.tbl_Interviewers.Where(x => x.InterviewerId == i.InterviewerId).Select(x => new Interviewer() { Forename = x.Forename, Surname = x.Surname, Email = x.Email, Id = x.InterviewerId, IsUser = false }).FirstOrDefault())); } } timeSlot.Interviewers = interviewers; return timeSlot; }
partial void Updatetbl_TimeSlot(tbl_TimeSlot instance);
partial void Deletetbl_TimeSlot(tbl_TimeSlot instance);
partial void Inserttbl_TimeSlot(tbl_TimeSlot instance);