public async Task <IActionResult> Index(NewSessionModel model) { if (!ModelState.IsValid) { if (Logger.useLogs) { Logger.Log.Warn("BadRequest"); } return(BadRequest(ModelState)); } else { await _sessionRepository.AddAsync(new BrainstormSession() { DateCreated = DateTimeOffset.Now, Name = model.SessionName }); if (Logger.useLogs) { Logger.Log.Info($"session name = {model.SessionName}"); } } return(RedirectToAction(actionName: nameof(Index))); }
public async Task InitializeDatabaseAsync(IBrainstormSessionRepository repo) { var sessionList = await repo.ListAsync(); if (!sessionList.Any()) { await repo.AddAsync(GetTestSession()); } }
/// <summary> /// Method for initialize database. /// </summary> /// <param name="repo">Interface of repository.</param> /// <returns>Nothing.</returns> public static async Task InitializeDatabaseAsync(IBrainstormSessionRepository repo) { if (repo is null) { throw new ArgumentNullException(nameof(repo)); } var sessionList = await repo.ListAsync(); if (!sessionList.Any()) { await repo.AddAsync(GetTestSession()); } }
public async Task <IActionResult> Index(NewSessionModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _sessionRepository.AddAsync(new BrainstormSession() { DateCreated = DateTimeOffset.Now, Name = model.SessionName }); return(RedirectToAction("Index")); }
public async Task <IActionResult> Index(NewSessionModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { await _sessionRepository.AddAsync(new BrainstormSession() { DateCreated = DateTimeOffset.Now, Name = model.SessionName }); } return(RedirectToAction(actionName: nameof(Index), controllerName: "Brainstorm")); }
public async Task <IActionResult> Index(NewSessionModel model) { if (!ModelState.IsValid) { Logger.Warn($"Passed model is not valid: {model}"); return(BadRequest(ModelState)); } else { await _sessionRepository.AddAsync(new BrainstormSession() { DateCreated = DateTimeOffset.Now, Name = model.SessionName }); } return(RedirectToAction(actionName: nameof(Index))); }