Exemple #1
0
        public ActionResult ForumView()
        {
            ForumPostSqlDAL  dal      = new ForumPostSqlDAL();
            List <ForumPost> allPosts = dal.GetAllPosts();

            return(View(allPosts));
        }
        public ActionResult ForumPost()
        {
            IForumPostDAL dal = new ForumPostSqlDAL();

            List <ForumPost> results = dal.GetAllPosts();

            return(View(results));
        }
Exemple #3
0
        public ActionResult ForumView(ForumPost forumPost)
        {
            ForumPostSqlDAL dal = new ForumPostSqlDAL();

            dal.SaveNewPost(forumPost);
            ForumPostSqlDAL  newdal   = new ForumPostSqlDAL();
            List <ForumPost> allPosts = newdal.GetAllPosts();

            return(View("ForumView", allPosts));
        }
        //public ActionResult Index()
        //{
        //  return RedirectToAction("Forum", "Planets"); //<-- if user goes to .com/ this redirects to .com/planets/index
        //}
        public ActionResult Forum()
        {
            if (TempData["message"] == null)
            {
                TempData["message"] = "Welcome!";
            }

            ForumPostSqlDAL _dal = new ForumPostSqlDAL();

            var model = _dal.GetAllPosts();

            return(View("Forum", model));
        }
        public ActionResult PostAMessage()
        {
            if (Request.Params["Username"] != null)
            {
                IForumPostDAL dal  = new ForumPostSqlDAL();
                ForumPost     post = new ForumPost();

                post.Username = Request.Params["Username"];
                post.Subject  = Request.Params["Subject"];
                post.Message  = Request.Params["Message"];

                bool result = dal.SaveNewPost(post);

                ViewBag.Result = result;
            }

            return(View());
        }
        public ActionResult NewPost(ForumPost model)
        {
            ForumPostSqlDAL _dal = new ForumPostSqlDAL();

            bool successful = _dal.SaveNewPost(model);

            //If successful:

            if (successful)
            {
                SetMessage("Your post was successfully added");
            }
            else
            {
                SetMessage("There was an error adding your post!");
            }

            return(RedirectToAction("Forum"));
        }
 public ForumController(ForumPostSqlDAL fpDAL)
 {
     _fpDAL = fpDAL;
 }
Exemple #8
0
 // GET: Home
 public HomeController()
 {
     forumDAL = new ForumPostSqlDAL(connectionString);
 }
 public ForumController(ForumPostSqlDAL forumPostSqlDAL)
 {
     this.forumPostSqlDAL = forumPostSqlDAL;
 }