示例#1
0
        public ActionResult Edit(Post post)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
示例#2
0
        public ActionResult Create(Post p)
        {
            try
            {
                p.Author = (SiteUser)Session["CurrentUser"];
                p.Author.TryMakePost(p.Description, p.Text);

                Posts.Add(p);
                return RedirectToAction("Index");
            }
            catch
            {
                return new HttpStatusCodeResult(401);
            }
        }
示例#3
0
 public Post TryMakePost(string description, string text)
 {
     var newPost = new Post
     {
         Author = this,
         DateTimeSubmitted = DateTime.Now,
         Description = description,
         Text = text,
         Id = Guid.NewGuid()
     };
     return newPost;
 }