private DynPermFullData(DynamicPerms perms, string pastebinUrl) { Perms = perms; PastebinUrl = pastebinUrl; if (string.IsNullOrEmpty(pastebinUrl)) IsDirty = true; }
private DynPermFullData(DynamicPerms perms, string pastebinUrl) { Perms = perms; PastebinUrl = pastebinUrl; if (string.IsNullOrEmpty(pastebinUrl)) { IsDirty = true; } }
public DynPermFullData SetDynPermFullData(ulong serverId, string input, out string error) { try { DynamicPerms perms = JsonConvert.DeserializeObject <DynamicPerms>(input); if (perms == null) { error = "Deserialization of input resulted in null params."; return(null); } DynPermFullData fullPermData = new DynPermFullData(perms); Server server = _client.GetServer(serverId); // verify the data (role && user ids) if (server == null) { error = $"Server id {serverId} not found."; return(null); } foreach (var pair in fullPermData.Perms.RolePerms) { ulong invalidChannelId; if (IsInvalidChannelsInBlock(pair.Value, server, out invalidChannelId)) { error = $"Channel id {invalidChannelId} not found."; return(null); } } foreach (var pair in fullPermData.Perms.UserPerms) { if (server.GetUser(pair.Key) == null) { error = $"User id {pair.Key} not found."; return(null); } } // data looks fine, add the dynrole to the dict. _perms.AddOrUpdate(serverId, fullPermData, (k, v) => fullPermData); error = null; return(fullPermData); } catch (Exception ex) { error = $"Failed deserializing input. Make sure your input is valid JSON.\r\nDebug: ```{ex.GetType().Name}: {ex.Message}:{ex.TargetSite}```"; } return(null); }
public DynPermFullData(DynamicPerms perms) : this(perms, null) { }