private List <MinimalSpeakerModel> GetSpeakersFor(int sessionId, SqlConnection connection) { var speakersIdCommand = new SqlCommand("SELECT SpeakerId from SessionsSpeakers " + "WHERE SessionId = @SessionId", connection); var sessionParameter = new SqlParameter { ParameterName = "@SessionId", Value = sessionId }; speakersIdCommand.Parameters.Add(sessionParameter); var speakerReader = speakersIdCommand.ExecuteReader(); var speakers = new List <MinimalSpeakerModel>(); while (speakerReader.Read()) { var speakerId = speakerReader.GetInt32(0); var speaker = _speakerRepository.Get(speakerId); speakers.Add(new MinimalSpeakerModel { Id = speaker.Id, Name = speaker.Name, Links = new List <LinkModel>() }); } speakerReader.Close(); return(speakers); }
public IHttpActionResult Get(int speakerId) { var speaker = _speakerRepository.Get(speakerId); var speakerWithSelfLink = AddSelfLinkTo(speaker); speakerWithSelfLink.Sessions = speakerWithSelfLink.Sessions.Select(AddSelfLinkTo); return(Ok(speakerWithSelfLink)); }
public FileContentResult Index(Guid id) { var speaker = speakerRepository.Get(id); var csv = "Title,Speaker,Length,ScheduledAt" + Environment.NewLine; var offset = TimeSpan.FromHours(-11); foreach (var session in speaker.Sessions) { csv += $"{session.Title}, {speaker.Name}, {session.Length}, " + $"{session.ScheduledAt.ToOffset(offset).ToString("o")}{Environment.NewLine}"; } return(File(Encoding.UTF8.GetBytes(csv), "text/csv", $"sessions for {speaker.Name}.csv")); }
public FileContentResult Index(Guid id) { var speaker = speakerRepository.Get(id); var csv = "Title,Speaker,Length,ScheduledAt" + Environment.NewLine; // the offset is an example of a user passing in a date var offset = TimeSpan.FromHours(-11); DateTimeOffset.UtcNow.ToUnixTimeSeconds(); foreach (var session in speaker.Sessions) { // toString("o") converts date to ISO 8601 format // add .ToOffset to set the date and time to the given timezone offset csv += $"{session.Title},{speaker.Name},{session.Length},{session.ScheduledAt.ToOffset(offset).ToString("o")}{Environment.NewLine}"; } // Create and return the CSV file return(File(Encoding.UTF8.GetBytes(csv), "text/csv", $"sessions for {speaker.Name}.csv")); }
public void OnGet() { Speaker = repository.Get("Filip Ekberg"); }
// GET: Speaker public ActionResult Index() { var speakers = _speakerRepository.Get().Select(s => Map(s, _conferences)); return(View(speakers)); }