public MsgFriend(RelationAction mode, uint targetId, string targetName, bool online) : base(PacketType.MSG_FRIEND, 48, 40) { Mode = mode; Identity = targetId; Name = targetName; Online = online; }
public async Task RefuseFriend(RelationAction relationAction) { var result = await DoCommand(async() => { var playerId = _account.PlayerId; var command = new RefuseFriendCommand(playerId, relationAction.RelationId); await _bus.SendCommand(command); }); }
public ApplicationResult ActionUser(RelationAction action, string userId, string currentUserId) { var message = _userRepository.ActionUser(action, userId, currentUserId); return(string.IsNullOrEmpty(message) ? ApplicationResult.Ok() : ApplicationResult.Fail(message)); }
public string ActionUser(RelationAction action, string userId, string currentUserId) { using (var db = new ApplicationDbContext()) { var currentUser = db.Users.Single(x => x.Id == currentUserId); if (currentUser == null) { return("Current User does not exist"); } var user = db.Users.Single(x => x.Id == userId); if (user == null) { return("User does not exist"); } var relation = db.UserRelationShips.FirstOrDefault(x => x.CurrentUserId == currentUserId && x.OtherUserId == userId); if (relation == null) { relation = new UserRelationShip() { CurrentUserId = currentUserId, OtherUserId = userId, CreateBy = currentUserId, } } ; switch (action) { case RelationAction.Away: relation.Ignored = !relation.Ignored; break; case RelationAction.Friend: relation.IsFriend = !relation.IsFriend; var otherRelation = db.UserRelationShips.FirstOrDefault(x => x.CurrentUserId == userId && x.OtherUserId == currentUserId); if (otherRelation == null) { otherRelation = new UserRelationShip() { CurrentUserId = userId, OtherUserId = currentUserId, CreateBy = userId, } } ; otherRelation.IsFriend = relation.IsFriend; break; case RelationAction.Block: relation.IsBlock = !relation.IsBlock; break; } if (relation.Id == 0) { db.UserRelationShips.Add(relation); } else { db.UserRelationShips.Update(relation); } db.SaveChanges(); return(string.Empty); } } }
/// <summary> /// modify the relation between current user and other user /// </summary> /// <param name="userid">other user id</param> /// <param name="action">action to perform on the relatioin</param> /// <returns>relation's status</returns> public async Task <RelationStatus> Self_ModifyRelation(string accesstoken, long userid, RelationAction action) { FormUrlEncodedContent content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("action", action.ToString()) }); RelationStatus status = new RelationStatus(); try { _ResponseMessage = await _HttpClient.PostAsync(_HttpClient.BaseAddress.AbsoluteUri + "users/" + userid.ToString() + "/relationship?access_token=" + accesstoken, content); if (_ResponseMessage.IsSuccessStatusCode) { string responsestring = await _ResponseMessage.Content.ReadAsStringAsync(); status = JsonConvert.DeserializeObject <RelationStatus>(responsestring); } else { status.meta.code = int.Parse(_ResponseMessage.StatusCode.ToString()); } return(status); } catch (Exception ex) { if (_Telemetryclient != null) { _Telemetryclient.TrackException(ex); } status.meta.code = int.Parse(_ResponseMessage.StatusCode.ToString()); } return(status); }
public IActionResult ActionUser(RelationAction action, string userId) { return(Result(() => (_userService).ActionUser(action, userId, CurrentUser.Id))); }