public async Task <IActionResult> ForSession(int sessionId) { var session = await _sessionRepository.GetByIdAsync(sessionId); if (session == null) { return(NotFound(sessionId)); } var drills = session.Drills.Select(drill => new DrillDto { Id = drill.Id, Name = drill.Name, Description = drill.Description, Duration = drill.Duration, DateCreated = drill.DateCreated }).ToList(); return(Ok(new SessionDrillContainer(session, drills))); }
public async Task <IActionResult> Index(int?id) { if (!id.HasValue) { return(RedirectToAction(actionName: nameof(Index), controllerName: "Home")); } var session = await _sessionRepository.GetByIdAsync(id.Value); if (session == null) { return(Content("Session not found.")); } var viewModel = new TrainingSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id, DrillCount = session.Drills.Count() }; return(View(viewModel)); }