private async Task AddFollowItem(int id, int followingId) { _followContext.FollowItems.Add(new FollowItem() { followerId = id, followingId = followingId }); await _followContext.SaveChangesAsync(); }
public async Task <IActionResult> FollowUser([FromBody] Follow follow) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } follow.FollowDate = DateTime.Now; _context.Follow.Add(follow); await _context.SaveChangesAsync(); return(Ok("Successfully followed a user")); }
public async Task CreateFollowWhileFollowExist() { var profile = new Profile { Id = new Guid(), DisplayName = "Roger", Avatar = "Test.png" }; var follow = new Follow { Profile = profile, Follower = profile }; _context.Follows.Add(follow); _context.Profile.Add(profile); await _context.SaveChangesAsync(); var response = await _followService.CreateFollow(profile.Id, profile.Id); Assert.False(response.Success); Assert.Null(response.Data); }
public async Task CreateProfileWhileProfileDoestExist() { var profile = new Profile { Id = Guid.Parse("7ad3918c-bbcb-4e8a-af79-4219940c9be0"), DisplayName = "Roger", Avatar = "Test.png" }; _context.Profile.Add(profile); await _context.SaveChangesAsync(); var message = "{\"Id\":\"7ad3918c-bbcb-4e8a-af79-4219940c9be0\",\"DisplayName\":\"Roger\",\"Avatar\":\"Test.png\"}"; var success = await _createProfileHandler.Consume(message); Assert.False(success); }