Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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)));
        }