public async Task <IActionResult> Follow(FollowDTO model) { if (!model.isExsist)//modelde veri yoksa { if (model.FollowerId == User.GetUserId()) { await _followService.Follow(model); return(Json("Success")); } else { return(Json("Faild")); } } else { if (model.FollowerId == User.GetUserId()) { await _followService.UnFollow(model); return(Json("Success")); } else { return(Json("Faild")); } } }
public async Task <IActionResult> Follow(string userToFollowId) { var userId = (await _userManager.GetUserAsync(User)).Id; await _followService.Follow(userId, userToFollowId); return(RedirectToAction("Index", "Profile", new { userId = userToFollowId })); }
public async Task <ActionResult> Follow(string userName) { await _followService.Follow(User.Identity.Name, userName, _ctx); var notification = await _notificationService.CreateNotification(userName, User.Identity.Name, string.Format("{0} has followed you.", User.Identity.Name), _ctx); await _notificationService.SendNotification(notification, _ctx); return(RedirectToAction("Details", "Profile", new { id = userName })); }
public ActionResult Create([Bind(Include = "Id,Name,Description,VisibilityType,LicenceType,Tags")] Project project) { if (ModelState.IsValid) { int newId = serviceProject.Create(project, CurrentUser); serviceFollow.Follow(newId, CurrentUser.Id); return(RedirectToAction("Detail", new { id = newId })); } return(View(project)); }
public async Task Follow_Should_FollowUser_Correctly() { // Arange var userToFollow = _fakeData.GetUser(); await _context.AddAsync(userToFollow); await _context.SaveChangesAsync(); // Act var result = await _followService.Follow(_userId, userToFollow.Id); // Assert var following = await _context.Follows.Where(x => x.UserId == _userId).ToListAsync(); Assert.True(result.Succeeded); Assert.AreEqual(1, following.Count); Assert.AreEqual(userToFollow.Id, following.First().FollowUserId); }
//JSON public IActionResult Follow(string Id) { return(new JsonResult(_followService.Follow(Id, User.Identity.Name))); }