public async Task <bool> ChangeNickName(ChangeNickNameRequestModel model) { var player = await GetPlayerById(model.PlayerId); if (player == null) { return(false); } var existNickName = await _context.PlayerIdentity.AnyAsync(t => t.Nick == model.NewNickName); if (existNickName) { return(false); } else { player.Nick = model.NewNickName; var dbResult = _context.PlayerIdentity.Update(player); player.PlayerHash = player.GetHashCode().ToString(); if (dbResult.State == EntityState.Modified) { await _context.SaveChangesAsync(); return(true); } } return(false); }
public async Task <bool> ChangeNickName(ChangeNickNameRequestModel model) { return(await _userService.ChangeNickName(model)); }