Exemplo n.º 1
0
        public ViewResult Story(string thestory, string username, string email, string title, bool ismember)
        {
            Story tale = new Story();

            tale.IsMember = ismember;
            tale.Title    = title;
            tale.TheStory = thestory;
            tale.Username = username;
            tale.Email    = email;
            tale.Date     = DateTime.Now;


            User user1 = new User();

            user1.IsMember = ismember;
            user1.UserName = username;
            user1.EMAIL    = email;

            StoryRepository.AddStory(tale);
            StoryRepository.AddUser(user1);

            ViewBag.storyCount = StoryRepository.GetStoryCount();
            ViewBag.userCount  = StoryRepository.GetUserCount();

            return(View("StoryPage", StoryRepository.Stories));
        }
Exemplo n.º 2
0
        public ViewResult UserList(string username)
        {
            User Username = new User();

            StoryRepository.AddUser(Username);

            ViewBag.storyCount = StoryRepository.GetStoryCount();
            ViewBag.userCount  = StoryRepository.GetUserCount();
            return(View("UserList", StoryRepository.UserNames));
        }
Exemplo n.º 3
0
        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));
            }
        }