public async Task <IHttpActionResult> PostRejectFriendRequest(int friendId) { User user = CurrentUser; if (user == null) { return(NotFound()); } UsersFriend friendship = await db.UsersFriends.FirstOrDefaultAsync(uf => uf.UserId == friendId && uf.FriendId == user.UserId && uf.IsConfirmed == false); if (friendship == null) { return(NotFound()); } db.UsersFriends.Remove(friendship); await db.SaveChangesAsync(); return(Ok()); }
public async Task <IHttpActionResult> PostConfirmRequest(int friendId) { User user = CurrentUser; if (user == null) { return(NotFound()); } UsersFriend friendship = await db.UsersFriends .FirstOrDefaultAsync(uf => uf.UserId == friendId && uf.FriendId == user.UserId && uf.IsConfirmed == false); if (friendship == null) { return(NotFound()); } friendship.IsConfirmed = true; db.Entry(friendship).State = EntityState.Modified; await db.SaveChangesAsync(); return(Ok()); }