예제 #1
0
        public UserData(BaseUserData data)
        {
            id        = data.id;
            discordId = data.discordId;
            userName  = data.nickName;

            completedTournaments = new List <CompletedTournaments>();
            ongoingTournaments   = new List <CompletedTournaments>();

            ongoingCreatedTournaments   = new List <CompletedTournaments>();
            completedCreatedTournaments = new List <CompletedTournaments>();
        }
예제 #2
0
        public static async Task <bool> CreateUser(BaseUserData value)
        {
            if (!Cryptography.CryptographyModule.IsSignatureValid(value.signature, value.id))
            {
                return(false);
            }
            var collec = Models.DatabaseConnection.GetDb().GetCollection <UserData>("Users");
            var user   = (await collec.FindAsync(u => u.id == value.id.ToLower())).FirstOrDefault();

            if (user == null)
            {
                value.id = value.id.ToLower();
                await collec.InsertOneAsync(new UserData(value));

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        public static async Task <bool> UpdateUser(BaseUserData value)
        {
            if (!Cryptography.CryptographyModule.IsSignatureValid(value.signature, value.id))
            {
                return(false);
            }
            var collec = Models.DatabaseConnection.GetDb().GetCollection <UserData>("Users");
            var user   = (await collec.FindAsync(u => u.id == value.id.ToLower())).FirstOrDefault();

            if (user != null)
            {
                user.userName  = value.nickName;
                user.discordId = value.discordId;
                await collec.ReplaceOneAsync(u => u.id == value.id.ToLower(), user);

                return(true);
            }
            else
            {
                return(false);
            }
        }