示例#1
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         int postid = Convert.ToInt32(RouteData.Values["id"]);
         if (User.Identity.IsAuthenticated)
         {
             int userid = userService.GetAll()
                          .Where(user => user.Email.Equals(User.Identity.Name))
                          .FirstOrDefault().UserId;
             commentService.Create(
                 new Comments()
             {
                 PostId      = postid,
                 UserId      = userid,
                 commentText = collection["text"].ToString()
             });
         }
         return(RedirectToAction("Details", "Posts", new { id = postid }));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#2
0
 public ActionResult Users()
 {
     return(View(service.GetAll().Select(user => user)));
 }