Exemplo n.º 1
0
        public ActionResult EditPublicProfile(PublicProfile publicProfile)
        {
            var currentUserId = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                using (var db = new PubContext())
                {
                    db.Entry(publicProfile).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index", "Home");
                }
            }
            return View(publicProfile);
        }
Exemplo n.º 2
0
        public ActionResult EditPublicProfile()
        {
            var currentUserId = User.Identity.GetUserId();
            using (var db = new ApplicationDbContext())
            {
                var userProfileImageUri = db.Users.FirstOrDefault(u => u.Id == currentUserId).ProfileImageUri;
                ViewBag.ProfileImageUri = userProfileImageUri;
            }
            using (var db = new PubContext())
            {
                var userProfile = db.PublicProfiles.FirstOrDefault(p => p.UserId == currentUserId);
                if (userProfile == null)
                {
                    userProfile = new PublicProfile() { UserId = currentUserId };
                    db.PublicProfiles.Add(userProfile);
                    db.SaveChanges();
                }

                return View(userProfile);
            }
        }