Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [14:34:56] Pavel Dvorkin:
- public async Task<bool> AddClanMember(int id, int newMemberId, int clanId, ClanRole role)
- {
- using (var connection = await GetConnection())
- {
- await ExecuteNonQueryAsync(connection, "LOCK TABLES userclan WRITE, clans WRITE;");
- if (await IsPlayerInClan(connection, newMemberId) || !await CanMemberBeAddedToClan(connection, clanId) || !await CanPlayerAddMembersToClan(connection, id, clanId))
- {
- await ExecuteNonQueryAsync(connection, "UNLOCK TABLES;");
- return false;
- }
- var rowsAffected = await ExecuteNonQueryAsync(
- connection,
- "INSERT INTO userclan (fid_user, fid_clan, fclanrole) VALUES (@id, @fid_clan, @fclanrole);",
- Param("@id", id),
- Param("@fid_clan", clanId),
- Param("@fclanrole", (int)role)
- );
- await ExecuteNonQueryAsync(connection, "UNLOCK TABLES;");
- return rowsAffected > 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement