private List <Room> AddRooms(CodeCamperDbContext context) { // Total number of rooms = (number of tracks) + (number of TheChosen people); see note in TheChosen. var names = new[] { // 'Track' rooms (10 in use) "Surf A", "Surf B", "Mendocino A", "Mendocino B", "Mendocino C", "Stromboli", "Chico", "Frisco", "Miami", "Boston", "Venice", "Rome", "Paris", "Madrid", "London", // 'TheChosen' rooms (13 in use) "Levenworth", "Pelham Bay", "San Quentin", "Alcatraz", "Folsom", "Aqueduct", "Saratoga", "Golden Gate", "Santa Anita", "Monmouth Park", "Ossining", "Danbury", "Allenwood", "Lompoc", "La Tuna", "Caliente", "Churchill Downs", "Calder", "Del Mar", "Hollywood Park" }; var rooms = new List <Room>(); Array.ForEach(names, name => { var item = new Room { Name = name }; rooms.Add(item); context.Rooms.Add(item); }); context.SaveChanges(); return(rooms); }
private List <Person> AddPersons(CodeCamperDbContext context, int count) { var persons = new List <Person>(); AddKnownAttendees(persons); TheChosen.AddPersons(persons); AddTheCrowd(count, persons); persons.ForEach(p => context.Persons.Add(p)); context.SaveChanges(); return(persons); }
// GET api/speakers public IEnumerable<object> Get() { var ctx = new CodeCamperDbContext(); var query = ctx.Set<Session>() .Select(session => session.Speaker) .Distinct().Select(s => new { Id = s.Id, FirstName = s.FirstName, LastName = s.LastName, ImageSource = s.ImageSource, }); return query; }
private void AddAttendance(CodeCamperDbContext context, IEnumerable <Person> attendees) { var attendanceList = new List <Attendance>(); var textGenerator = new SampleTextGenerator(); const SampleTextGenerator.SourceNames textSource = SampleTextGenerator.SourceNames.Faust; // NEEDED FOR RANDOMIZING WHICH WE NO LONGER DO // Unique TimeSlot.Ids and Ids of Sessions in those slots //var slotAndSessionIds = GetSlotAndSessionIds(sessions); //var numberOfAttendedSessions = Math.Min(slotAndSessionIds.Count(), 8); var sids = TheChosen.ChoosenAttendeeSessions .Select(s => s.Id).ToList(); foreach (var person in attendees) { // NO LONGER RANDOMIZING ASSIGNMENTS //var sids = GetRandomAttendeeSessionIds( // numberOfAttendedSessions, // slotAndSessionIds); var evalCount = 4; // person evals the first 'n' sessions attended foreach (var sid in sids) { var attendance = new Attendance { PersonId = person.Id, SessionId = sid, }; attendanceList.Add(attendance); if (evalCount <= 0) { continue; } attendance.Rating = Rand.Next(1, 6);// rating in 1..5 attendance.Text = textGenerator.GenSentences(10, textSource); evalCount--; } } // Done populating Attendance attendanceList.ForEach(ps => context.Attendance.Add(ps)); context.SaveChanges(); }
private List <Track> AddTracks(CodeCamperDbContext context) { var names = SampleTrack.Names; var tracks = new List <Track>(); names.ForEach(name => { var item = new Track { Name = name }; tracks.Add(item); context.Tracks.Add(item); }); context.SaveChanges(); return(tracks); }
protected override void Seed(CodeCamperDbContext context) { // Seed code here var rooms = AddRooms(context); var tracks = AddTracks(context); // Keep well-known sessions in separate room from generated sessions _roomsForGeneratedSessions = rooms.Take(tracks.Count).ToList(); _roomsForWellKnownSessions = rooms.Skip(tracks.Count).ToList(); var timeSlots = AddTimeSlots(context); var persons = AddPersons(context, AttendeeCount); AddSessions(context, persons, timeSlots, tracks); AddAttendance(context, persons.Take(AttendeesWithFavoritesCount).ToArray()); }
// TODO: We never use this methods // but let's keep it here just in case. private List <Session> AddSessions( CodeCamperDbContext context, IList <Person> persons, IEnumerable <TimeSlot> timeSlots, IList <Track> tracks) { var slots = timeSlots.Where(t => t.IsSessionSlot).ToArray(); var knownSessions = TheChosen.AddSessions( slots, tracks, _levels, _roomsForWellKnownSessions); var sessions = new List <Session>(knownSessions); AddGeneratedSessions(sessions, persons, slots, tracks); // Done populating sessions sessions.ForEach(s => context.Sessions.Add(s)); context.SaveChanges(); return(knownSessions); // return sessions; }
// GET api/sessions public IEnumerable<object> Get() { var ctx = new CodeCamperDbContext(); var query = ctx.Sessions.Select(s => new { Id = s.Id, Title = s.Title, Code = s.Code, SpeakerId = s.SpeakerId, SpeakerFirstName = s.Speaker.FirstName, SpeakerLastName = s.Speaker.LastName, SpeakerImageSource = s.Speaker.ImageSource, TrackId = s.TrackId, TrackName = s.Track.Name, TimeSlotId = s.TimeSlotId, TimeSlotStart = s.TimeSlot.Start, RoomId = s.RoomId, RoomName = s.Room.Name, Level = s.Level, Tags = s.Tags, }); return query; }
private List <TimeSlot> AddTimeSlots(CodeCamperDbContext context) { var seed1 = new DateTime(2013, 5, 18, 8, 0, 0); var seed2 = new DateTime(2013, 5, 19, 8, 0, 0); var slots = new List <TimeSlot> { // Sat May 18, 2013 - Registration new TimeSlot { Start = seed1, Duration = 45, IsSessionSlot = false }, (_keyNoteTimeSlot = new TimeSlot { Start = seed1 = seed1.AddMinutes(60), Duration = 60 }), new TimeSlot { Start = seed1 = seed1.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed1 = seed1.AddMinutes(70), Duration = 60 }, // Lunch new TimeSlot { Start = seed1 = seed1.AddMinutes(60), Duration = 60, IsSessionSlot = false }, new TimeSlot { Start = seed1 = seed1.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed1 = seed1.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed1 = seed1.AddMinutes(70), Duration = 60 }, // Close new TimeSlot { Start = seed1.AddMinutes(70), Duration = 30, IsSessionSlot = false }, // Sun May 19, 2013 - Registration new TimeSlot { Start = seed2, Duration = 45, IsSessionSlot = false }, new TimeSlot { Start = seed2 = seed2.AddMinutes(60), Duration = 60 }, new TimeSlot { Start = seed2 = seed2.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed2 = seed2.AddMinutes(70), Duration = 60 }, // Lunch new TimeSlot { Start = seed2 = seed2.AddMinutes(70), Duration = 60, IsSessionSlot = false }, new TimeSlot { Start = seed2 = seed2.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed2 = seed2.AddMinutes(70), Duration = 60 }, new TimeSlot { Start = seed2.AddMinutes(70), Duration = 60 }, }; slots.ForEach(slot => context.TimeSlots.Add(slot)); context.SaveChanges(); return(slots); }
public Lookups(CodeCamperDbContext context) { _context = context; }