public ActionResult GetPosts(string currentId) { var currentUser = db.Accounts.Single(x => x.AccountId == currentId); var privateKey = (string)Session["privateKey"]; var model = new List<PostViewModel>(); foreach (var post in currentUser.Posts.OrderByDescending(x => x.Date)) { var modelPost = new PostViewModel(); var content = TextEncryption.DecryptionPost(post, currentUser); modelPost.Author = post.Author; modelPost.Content = content; modelPost.Date = post.Date; modelPost.Id = post.OrginId; modelPost.Rated = post.Rated; modelPost.Plus = post.Plus; modelPost.Minus = post.Minus; model.Add(modelPost); } return PartialView("_Posts", model); }
public ActionResult Index(string id) { var currentId = User.Identity.GetUserId(); var currentUser = db.Accounts.Single(x => x.AccountId==currentId); var post = currentUser.Posts.Single(x => x.OrginId == id); var model = new PostViewModel(); var content = TextEncryption.DecryptionPost(post, currentUser); model.Author = post.Author; model.Content = content; model.Date = post.Date; model.Id = post.OrginId; model.Rated = post.Rated; model.Plus = post.Plus; model.Minus = post.Minus; return View(model); }