예제 #1
0
        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();
        }
예제 #2
0
 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);
 }