示例#1
0
        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)));
        }
示例#2
0
 public async Task InitializeDatabaseAsync(IBrainstormSessionRepository repo)
 {
     var sessionList = await repo.ListAsync();
     if (!sessionList.Any())
     {
         await repo.AddAsync(GetTestSession());
     }
 }
示例#3
0
        /// <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());
            }
        }
示例#4
0
        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"));
        }
示例#5
0
        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"));
        }
示例#6
0
        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)));
        }
示例#7
-1
 public async Task InitializeDatabaseAsync(IBrainstormSessionRepository repo)
 {
     var sessionList = await repo.ListAsync();
     if (!sessionList.Any())
     {
         await repo.AddAsync(GetTestSession());
     }
 }