public IActionResult NewComment(string title, string commentText, string username) { Comment comment = new Comment(); comment.StoryTitle = title; comment.CommentText = commentText; comment.Username = username; comment.Date = DateTime.Now; User user1 = new User(); user1.UserName = username; //Adds user that is posting a comment to the user list. for (int i = 0; i < StoryRepository.usersList.Count; i++) //for loop checks to see if the user is already apart of the userList, and if not then it adds a default email. { if (StoryRepository.usersList[i] != user1) { user1.EMAIL = null; } } StoryRepository.AddUser(user1); ViewBag.storyCount = StoryRepository.GetStoryCount(); ViewBag.userCount = StoryRepository.GetUserCount(); if (ModelState.IsValid) //check if I need this { Story story = stories.GetStoryByTitle(title); stories.AddComment(story, comment, username); return(RedirectToAction("StoryPage")); } else { return(RedirectToAction("NewComment", comment.StoryTitle)); } }