public IHttpActionResult Follow(FollowingsDto followingDto) { var userId = User.Identity.GetUserId(); if (_dbContext.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == followingDto.FolloweeId)) { return(BadRequest("following already exists")); } var following = new Following { FollowerId = userId, FolloweeId = followingDto.FolloweeId }; _dbContext.Followings.Add(following); _dbContext.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingsDto dto) { var userId = User.Identity.GetUserId(); var exists = _db.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.ArtistId); // followee means the artist, user trying to follow; if (exists) { return(BadRequest("you are already folloing the artist")); } var following = new Followings() { FolloweeId = dto.ArtistId, FollowerId = userId }; _db.Followings.Add(following); _db.SaveChanges(); return(Ok()); }