//matches the id from wallpostdbcontext to the currently logged in id public ActionResult Post() { var ctx = new WallPostDbContext(); var userId = User.Identity.GetUserId(); return(View(new UserIndexViewModel { UserId = userId, WallPostList = ctx.WallPostList.Where(l => l.UserId == userId).ToList() })); }
public void AddPost(string userId, string name) { var ctx = new WallPostDbContext(); ctx.WallPostList.Add(new WallPost { Name = name, UserId = userId }); ctx.SaveChanges(); }
public ActionResult OtherPost(ApplicationUser userProfile) { ApplicationDbContext db = new ApplicationDbContext(); var id = userProfile.Id; var ctx = new WallPostDbContext(); return(View(new UserIndexViewModel { UserId = id, WallPostList = ctx.WallPostList.Where(l => l.UserId == id).ToList() })); }