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);
            }
        }
Exemplo n.º 3
0
        public ActionResult SeeRandomTenData()
        {
            var currentUserId = User.Identity.GetUserId();
            List<ApplicationUser> usersInQueue;
            List<PublicProfile> publicProfiles = new List<PublicProfile>();
            using (var db = new ApplicationDbContext())
            {
                var currentUser = db.Users.First(u => u.Id == currentUserId);
                currentUser.CooldownEnds = DateTime.Now.AddMinutes(1);
                db.Entry(currentUser).Property(u => u.CooldownEnds).IsModified = true;
                db.SaveChanges();

                usersInQueue = db.Users.Where(u => u.Id != currentUserId && u.IsInLine).Take(6).ToList();
            }
            using (var db = new PubContext())
            {
                foreach (var user in usersInQueue)
                {
                    publicProfiles.Add(db.PublicProfiles.FirstOrDefault(p => p.UserId == user.Id));
                }
            }
            return Json(publicProfiles);
        }