public async Task InitializeDatabaseAsync(ITrainingSessionRepository repo) { var sessionList = await repo.ListAsync(); if (!sessionList.Any()) { var sessions = GetInitSession(); foreach (var session in sessions) { await repo.AddAsync(session); } } }
public async Task <IActionResult> Index(NewSessionModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { await _sessionRepository.AddAsync(new TrainingSession() { DateCreated = DateTime.Now, Name = model.SessionName }); } return(RedirectToAction(actionName: nameof(Index))); }