public ActionResult Following() { var userId = User.Identity.GetUserId(); var followees = new FollowingViewModel() { Followees = _unitOfWork.Following.GetUserFollowees(userId), ShowActions = User.Identity.IsAuthenticated }; return(View("Following", followees)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var artists = _context.Followings .Where(a => a.FollowerId == userId) .Select(a => a.Followee).ToList(); var viewModel = new FollowingViewModel { Following = artists }; return(View(viewModel)); }
public async Task <IActionResult> GetFollowTo([FromBody] FollowingViewModel vm) { if (!ModelState.IsValid) { return(new BadResponseResult(ModelState)); } var follower = await SocialDb.Followers.GetFollowings(vm.UserId, vm.UserPageId, vm.PageParams.Offset, vm.PageParams.Count, vm.SearchedLogin); return(new OkResponseResult(follower.MapToUserContactsViewModel(MediaConverter))); // return new BadResponseResult("Something goes wrong. We will fix it!... maybe)))"); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var following = _dbContext.Followings.Where(a => a.FollowerId == userId) .Select(a => a.Followee) .ToList(); var viewModel = new FollowingViewModel { FollowingCourses = following, ShowAction = User.Identity.IsAuthenticated }; return(View(viewModel)); }
public ActionResult Submit(FollowingViewModel objfollowingViewModel) { using (TwitterContext db = new TwitterContext()) { List <User> objUsersList = new List <Models.User>(); objUsersList.AddRange(db.Users); Following objFollowing = new Following(); objFollowing.Following_id = objUsersList.Where(e => e.Username == objfollowingViewModel.Username).FirstOrDefault().User_id; objFollowing.User_id = objfollowingViewModel.Current_user_id; db.FollowingList.Add(objFollowing); db.SaveChanges(); //Session["username"]= objUsersList.Where(e => e.User_id == objfollowingViewModel.Current_user_id).FirstOrDefault().Username.ToString(); return(RedirectToAction("Index", "Home", new { username = objUsersList.Where(e => e.User_id == objfollowingViewModel.Current_user_id).FirstOrDefault().Username.ToString() })); } }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var lecturers = _dbContext.Followings .Where(a => a.FollowerId == userId) .Select(a => a.Followee) .ToList(); var viewModel = new FollowingViewModel { UpcomingLecturers = lecturers, ShowAction = User.Identity.IsAuthenticated }; ViewBag.Followings = _dbContext.Followings.ToList(); return(View(viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var followees = _context.Followings .Where(a => a.FollowerId == userId) .Select(a => a.Followee) .ToList(); var viewModel = new FollowingViewModel() { ShowActions = User.Identity.IsAuthenticated, Followees = followees }; return(View("Following", viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var following = _context.Followings .Where(a => a.FolloweeId == userId) .Select(n => n.Followee) .Include(n => n.Name) .ToList(); var viewModel = new FollowingViewModel { Following = following }; return(View(viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var followingArtists = _context.Followings .Where(f => f.FollowerId == userId) .Select(f => f.Followee) .ToList(); FollowingViewModel viewModel = new FollowingViewModel() { User = followingArtists }; return(View(viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var follows = _dbContext.Followings .Where(a => a.FollowerId == userId) .Select(a => a.Followee) .Include(l => l.Followees).ToList(); var viewModel = new FollowingViewModel { UpcommingFollowing = follows, ShowAction = User.Identity.IsAuthenticated }; return(View(viewModel)); }
public ActionResult AllFollowings() { var currentUserId = User.Identity.GetUserId(); var followers = db.Followings .Where(u => u.FolloweeId == currentUserId) .Select(f => f.Follower) .ToList(); var viewModel = new FollowingViewModel() { Followers = followers, ShowActions = User.Identity.IsAuthenticated }; return(View(viewModel)); }
public ActionResult Following() { var userId = User.Identity.GetUserId(); var follows = _context.Followings .Where(a => a.FollowerId == userId) .Include(a => a.Followee) .ToList(); var viewModel = new FollowingViewModel() { FollowedArtist = follows, ShowActions = User.Identity.IsAuthenticated, Heading = "Followed Artists" }; return(View("Follows", viewModel)); }
public ActionResult Search(string strSearch) { using (TwitterContext db = new TwitterContext()) { FollowingViewModel objfollowingViewModel; List <User> objUserList = new List <Models.User>(); objUserList.AddRange(db.Users); var onbj = objUserList.Where(e => e.Username.ToUpper().Equals(strSearch.ToUpper())).FirstOrDefault(); if (onbj != null) { objfollowingViewModel = new FollowingViewModel(); objfollowingViewModel.Username = onbj.Username; objfollowingViewModel.Current_user_id = objUserList.Where(e => e.Username == Session["username"].ToString()).FirstOrDefault().User_id; return(RedirectToAction("Search", "Search", objfollowingViewModel)); } return(View()); } }
public ActionResult FollowedUser() { var userId = User.Identity.GetUserId(); var followedUsers = _context.Followings .Where(f => f.FollowerId == userId) .Select(g => g.Followee) .ToList(); var viewModel = new FollowingViewModel { FollowedUsers = followedUsers, ShowActions = User.Identity.IsAuthenticated, Heading = "The Users Following Me " }; return(View(viewModel)); }
public async Task <IHttpActionResult> Unfollow(FollowingViewModel model) { string userId = User.Identity.GetUserId(); if (!Context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == model.FolloweeId)) { return(BadRequest("You've not followed this lecturer yet!")); } Following following = await Context.Followings.FirstOrDefaultAsync(f => f.FollowerId == userId && f.FolloweeId == model.FolloweeId); Context.Followings.Remove(following); await Context.SaveChangesAsync(); return(Ok()); }
public async Task <IHttpActionResult> Follow(FollowingViewModel model) { string userId = User.Identity.GetUserId(); if (Context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == model.FolloweeId)) { return(BadRequest("Following already existed")); } Following following = new Following() { FollowerId = userId, FolloweeId = model.FolloweeId }; Context.Followings.Add(following); await Context.SaveChangesAsync(); return(Ok()); }
// GET: Search public ActionResult Search(FollowingViewModel objfollowingViewModel) { return(View(objfollowingViewModel)); }
public IActionResult Following(string userName) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("LoginOrRegister", "Account")); } if (userName == null || userName == "") { userName = _userManager.GetUserName(User); } var user = _context.Users.Where(x => x.UserName.ToLower() == userName.ToLower()).SingleOrDefault(); if (user == null) { TempData["error"] = "Unable to find user " + userName + "."; return(RedirectToAction(nameof(Home))); } Random random = new Random(); string realUserName = user.UserName; string loggedInUserId = _userManager.GetUserId(User); int barksCount = _context.Posts.Where(p => p.Author == userName).Count(); int followingCount = _context.Follows.Where(f => f.FollowerId == user.Id).Count(); int followersCount = _context.Follows.Where(f => f.FolloweeId == user.Id).Count(); int likesCount = _context.Likes.Where(l => l.UserId == user.Id).Count(); var following = _context.Follows.Where(f => f.FollowerId == loggedInUserId).Select(f => f.FolloweeId).ToList(); following = _context.Users.Where(u => following.Contains(u.Id)).Select(u => u.UserName).ToList(); var userNames = _context.Users.Select(u => u.UserName).Where(x => x != _userManager.GetUserName(User)).OrderBy(x => random.Next()).Take(10).ToList(); var profileImageId = user.ProfileImageId; // Getting the list of users followed by the specified user string userId = _context.Users.Single(u => u.UserName == realUserName).Id; var followingUsersIds = _context.Follows.Where(f => f.FollowerId == userId).Select(f => f.FolloweeId).ToList(); var followingUsers = _context.Users.Where(u => followingUsersIds.Contains(u.Id)).ToList(); // Putting the users into the correct list format var formattedUserList = new List <FollowingUser>(); foreach (var fUser in followingUsers) { formattedUserList.Add(new FollowingUser { UserName = fUser.UserName, BarksCount = _context.Posts.Count(p => p.User == fUser), FollowersCount = _context.Follows.Count(f => f.FolloweeId == fUser.Id), isFollowing = _context.Follows.Any(f => f.FolloweeId == fUser.Id && f.FollowerId == loggedInUserId) }); } var model = new FollowingViewModel { UserName = realUserName, BarksCount = barksCount, FollowingCount = followingCount, FollowersCount = followersCount, LikesCount = likesCount, JoinDate = user.JoinDate, Bio = user.Bio, ProfileImageId = profileImageId, Following = following, OtherUsers = userNames, FollowingUsers = formattedUserList }; return(View(model)); }
public FollowingPage() { InitializeComponent(); BindingContext = new FollowingViewModel(); }
public FollowingPage(ProfileDto profile) { InitializeComponent(); BindingContext = new FollowingViewModel(profile); }
public async Task <ActionResult> Following(string user, string avatar) { return(View(await FollowingViewModel.GetFollowers(user, avatar))); }