public async Task <int> Create(FollowChannelRequest request) { var flChannel = new FollowChannel(); flChannel.FromUserId = request.FromUserId; flChannel.ToUserId = request.ToUserId; flChannel.Notifications = true; _contex.FollowChannel.Add(flChannel); return(await _contex.SaveChangesAsync()); }
public async Task <IActionResult> UpdateFollow(FollowChannelRequest follow) { var result = await _followChannel.UpdateNotifi(follow); if (result > 0) { return(Content("Success")); } return(Content("Error")); }
public async Task <int> UpdateNotifi(FollowChannelRequest request) { var follow = _contex.FollowChannel.FirstOrDefault(X => X.FromUserId == request.FromUserId && X.ToUserId == request.ToUserId); if (follow != null) { follow.Notifications = false; _contex.Update(follow); return(await _contex.SaveChangesAsync()); } return(-1); }