public ActionResult NewBlogSubmit(string text, int id) { PersonModel blogger = Db.People.Where(bl => bl.Id == id).FirstOrDefault(); if (blogger != null) { BlogPost item = new BlogPost(); item.blog = text; blogger.blogPosts.Add(item); } //Db.CurrentBlogger = blogger; Db.SaveChanges(); return View("MyBlogs", Db.CurrentBlogger); }
public ActionResult NewComment(PersonModel model) { PersonModel person = Db.People.Where(p => p.Id == model.Id).FirstOrDefault(); if (person != null) { BlogPost bp = new BlogPost(); bp.comments.Add(model.newComment); person.blogPosts.Add(bp); model.newComment = ""; Db.SaveChanges(); return View("MyBlogs", new { model = person }); } else { return View("MyBlogs"); } }
public ActionResult NewBlog(PersonModel model) { PersonModel person = Db.People.Where(p => p.Id == model.Id).FirstOrDefault(); if (person != null) { BlogPost bp = new BlogPost(); bp.blog = model.newBlog; person.blogPosts.Add(bp); //db.Blogs.Add(bp); model.newBlog = ""; //Db.CurrentBlogger = person; } //person.blogPosts = db.Blogs.Where(b => b.bloggerId == person.Id).ToList(); Db.SaveChanges(); return View("MyBlogs", Db.CurrentBlogger); }