示例#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));
        }
示例#2
0
 public ViewResult StoryPage()
 {
     StoryRepository.storyList.Sort((s1, s2) => DateTime.Compare(s1.Date, s2.Date)); //Sort the stories by date on the page when it's called.
     ViewBag.storyCount = StoryRepository.GetStoryCount();
     ViewBag.userCount  = StoryRepository.GetUserCount();
     return(View("StoryPage", StoryRepository.Stories));
 }
示例#3
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));
        }
示例#4
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));
            }
        }
示例#5
0
 public IActionResult NewComment(string title)
 {
     ViewBag.storyCount = StoryRepository.GetStoryCount();
     ViewBag.userCount  = StoryRepository.GetUserCount();
     return(View("NewComment", HttpUtility.HtmlDecode(title)));
 }
示例#6
0
 public ViewResult UserList()
 {
     ViewBag.storyCount = StoryRepository.GetStoryCount();
     ViewBag.userCount  = StoryRepository.GetUserCount();
     return(View(StoryRepository.UserNames));
 }
示例#7
0
 public ViewResult Story()
 {
     ViewBag.storyCount = StoryRepository.GetStoryCount();
     ViewBag.userCount  = StoryRepository.GetUserCount();
     return(View("Story"));
 }