public AdditionalBuddyDetail GetAdditionalBuddyById(int additionalBuddyId) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .AdditionalBuddies .SingleOrDefault(a => a.AdditionalBuddyId == additionalBuddyId); var additionalBuddyDetail = new AdditionalBuddyDetail() { AdditionalBuddyId = entity.AdditionalBuddyId, BuddyId = entity.BuddyId, BuddyName = entity.Buddy.Name, TripId = entity.TripId, }; return(additionalBuddyDetail); } }
public TripDetail GetTripById(int id)// -- need to make user specific { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Trips .SingleOrDefault(b => b.TripId == id); var additionalBuddies = new List <AdditionalBuddyDetail>(); foreach (var buddy in entity.AdditionalBuddies) { var b = new AdditionalBuddyDetail() { AdditionalBuddyId = buddy.AdditionalBuddyId, BuddyId = buddy.BuddyId, BuddyName = buddy.Buddy.Name, TripId = buddy.TripId }; additionalBuddies.Add(b); } return(new TripDetail { TripId = entity.TripId, StartTime = entity.StartTime, BuddyId = entity.BuddyId, BuddyName = entity.Buddy.Name, VolunteerId = entity.VolunteerId, VolunteerName = entity.Volunteer.Name, StartLocation = entity.StartLocation, ProjectedEndLocation = entity.ProjectedEndLocation, EndLocation = entity.EndLocation, EndTime = entity.EndTime, AdditionalBuddies = additionalBuddies }); } }