Exemplo n.º 1
0
 public ActionResult CreatePost(Guid? threadID = null)
 {
     var post = new Post();
     if (threadID.HasValue)
         post.ThreadID = threadID.Value;
     return View(post);
 }
Exemplo n.º 2
0
        public ActionResult CreatePost(Post post)
        {
            if ( ModelState.IsValid )
            {
                Repository.Instance.Save<Post>(post);
                ForumThread forumthread = new ForumThread();
                Repository.Instance.Save<ForumThread>( forumthread );
                post.ThreadID = forumthread.ID;
                forumthread.Title = post.Title;
                forumthread.CreateDate = post.CreateDate;
                post.CreatedByID = Repository.Instance.GetUserByUserName( User.Identity.Name ).ID;

                return RedirectToAction("Thread", "Forums", new { id = forumthread.ID });
            }
            string msg = "Invalid input."; //Fixa ett felmeddelande
            return View(msg);
        }
Exemplo n.º 3
0
        public ActionResult CreatePost(Post post)
        {
            if (ModelState.IsValid)
                {
                    ForumThread thread = new ForumThread();
                    thread.ID = Guid.NewGuid();
                    post.ThreadID = thread.ID;
                    post.CreateDate = DateTime.Now;
                    thread.Title = post.Title;
                    thread.CreateDate = DateTime.Now;
                    //post.CreatedByID = Guid.NewGuid();

                    Repository.Instance.Save<ForumThread>(thread);
                    Repository.Instance.Save<Post>(post);

                    return RedirectToAction("Thread", new { id = thread.ID });
                }
            return View();
        }
Exemplo n.º 4
0
        public ActionResult CreatePost(Post Post)
        {
            if (SessionManager.CurrentUser == null)
                return RedirectToAction("Index", "Forums");
            if (ModelState.IsValid) {

                ForumThread forumThread = new ForumThread();
                Repository.Instance.Save<Post>(Post);
                forumThread.ID = Guid.NewGuid();
                Post.ThreadID = forumThread.ID;
                forumThread.Title = Post.Title;

                if (SessionManager.CurrentUser != null) {
                    Post.CreatedByID = SessionManager.CurrentUser.ID;
                }
                Repository.Instance.Save<ForumThread>(forumThread);

                return RedirectToAction("Thread", "Forums", new { id = forumThread.ID });
            }

            return View();
        }
Exemplo n.º 5
0
        public ActionResult CreatePost(Post post, Guid? id )
        {
            if (ModelState.IsValid)
            {
                if (SessionManager.CurrentUser != null)
                {
                    post.CreatedByID = SessionManager.CurrentUser.ID;
                }

                if (id == null)
                {
                    ForumThread newthread = new ForumThread();

                    newthread.CreateDate = DateTime.Now;
                    newthread.Title = post.Title;

                    Repository.Instance.Save<ForumThread>(newthread);

                    post.ThreadID = newthread.ID;
                    post.CreateDate = DateTime.Now;

                    Repository.Instance.Save<Post>(post);

                    return RedirectToAction("Thread" + "/" + newthread.ID, "Forums");
                }
                else
                {
                    post.ThreadID = (Guid)id;
                    post.CreateDate = DateTime.Now;

                    Repository.Instance.Save<Post>(post);

                    return RedirectToAction("Thread" + "/" + id, "Forums");
                }

            }

            return View();
        }
Exemplo n.º 6
0
        public ActionResult CreatePost(Post post)
        {
            if (SessionManager.CurrentUser == null ||
                SessionManager.CurrentUser.userstatus != Models.Entities.User.UserStatus.Active)
                return RedirectToAction("Index", "Users");

            if (ModelState.IsValid)
            {
                post.CreatedByID = SessionManager.CurrentUser.ID;
                if (post.ThreadID == Guid.Empty) {
                    ForumThread thread = new ForumThread();
                    thread.Title = post.Title;
                    post.ThreadID = thread.ID;
                    Repository.Instance.Save<ForumThread>(thread);
                    Repository.Instance.Save<Post>(post);
                    return RedirectToAction("Thread", new { id = thread.ID });
                } else {
                    Repository.Instance.Save<Post>(post);
                    return RedirectToAction("Thread", new { id = post.ThreadID });
                }
            }

            return View();
        }
Exemplo n.º 7
0
 public ThreadViewModel()
 {
     post = new Post();
 }