public ActionResult Create(Post post) { if (ModelState.IsValid) { post.Date = DateTime.Now; post.Author = User.Identity.Name; int myid = (int)WebSecurity.CurrentUserId; post.UserID = myid.ToString(); db.Posts.Add(post); db.SaveChanges(); return RedirectToAction("Index"); } return View(); }
public ActionResult Edit(Post post) { if (ModelState.IsValid) { post.Date = DateTime.Now; post.Author = User.Identity.Name; int mu2 = (int)Membership.GetUser().ProviderUserKey; post.UserID = mu2.ToString(); db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(post); }