コード例 #1
0
      //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()
            }));
      }
コード例 #2
0
ファイル: ApiController.cs プロジェクト: jojjebror/AspDotNet
        public void AddPost(string userId, string name)
        {
            var ctx = new WallPostDbContext();

            ctx.WallPostList.Add(new WallPost
            {
                Name   = name,
                UserId = userId
            });
            ctx.SaveChanges();
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: jojjebror/AspDotNet
        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()
            }));
        }