Exemplo n.º 1
0
        public long VerifyUser(long id)
        {
            DatabaseManager.ExecutePut("Nutzerdaten", id, new Dictionary <string, string> {
                { "Verifiziert", "1" }
            });

            var user      = DatabaseManager.ExecuteGet("Nutzerdaten", id, GetUserKeyTableDictionary());
            var u         = Json.DeserializeObject(user);
            var email     = Json.GetKvpValue(u, "email", false);
            var vorname   = Json.GetKvpValue(u, "vorname", false);
            var nachname  = Json.GetKvpValue(u, "nachname", false);
            var abteilung = Json.GetKvpValue(u, "abteilung", false);

            var firstId = DatabaseManager.GetId($"SELECT * FROM Nutzerdaten WHERE Email={email} AND Verifiziert=1");

            if (firstId == null)
            {
                return(-1);
            }

            var newId = Convert.ToInt64(firstId);

            if (newId < id)
            {
                var userPost = new UserPost {
                    abteilung = Json.DeserializeString(abteilung), email = Json.DeserializeString(email), vorname = Json.DeserializeString(vorname), nachname = Json.DeserializeString(nachname)
                };
                if (!PutUser(Convert.ToInt64(firstId), userPost))
                {
                    return(-1);
                }

                DatabaseManager.ExecuteNonQuery($"UPDATE Buchungen SET Nutzer={newId} WHERE Nutzer={id}");
            }

            if (DatabaseManager.CountResults("SELECT * FROM Veranstalter WHERE Autorisiert=1") == 0 && DatabaseManager.CountResults($"SELECT * FROM Veranstalter WHERE Id={id}") == 1)
            {
                DatabaseManager.ExecutePut("Veranstalter", id, new Dictionary <string, string> {
                    { "Autorisiert", "1" }
                });
            }

            if (DatabaseManager.CountResults("SELECT * FROM Admins") == 0)
            {
                new AdminsModel().PostAdmin(id);
            }

            return(id);
        }
        public string GetEvents(List <string> events, string queryString)
        {
            var es     = events;
            var result = new List <string>();

            for (int i = 0; i < es.Count; i++)
            {
                var uid    = Json.GetKvpValue(es[i], "uid", false);
                var dbData = DatabaseManager.ExecuteGet("Veranstaltungen", Json.DeserializeString(uid), GetEventKeyTableDictionary());
                if (dbData != null)
                {
                    result.Add(Json.MergeObjects(new string[] { es[i], dbData }, true));
                }
            }

            var jsonData = Json.SerializeObject(new Dictionary <string, string> {
                { "veranstaltungen", Json.SerializeArray(result.ToArray()) }
            });

            return(Json.QueryJsonData(jsonData, queryString, -1, false, false, Json.ArrayEntryOrKvpValue.ArrayEntry));
        }
Exemplo n.º 3
0
 public string GetUsers(long[] ids)
 {
     return(DatabaseManager.ExecuteGet("Nutzerdaten", ids, GetUserKeyTableDictionary()));
 }
Exemplo n.º 4
0
 public string GetCalendars(long[] ids)
 {
     return(DatabaseManager.ExecuteGet("Kalender", ids, GetCalendarKeyTableDictionary()));
 }