public bool UpdateParticipantCount(long eventId)
        {
            var count = DatabaseManager.CountResults($"SELECT * FROM Teilnehmer WHERE Veranstaltung={eventId}");

            return(DatabaseManager.ExecutePut("Veranstaltungen", eventId, new Dictionary <string, string> {
                { "Teilnehmerzahl", count.ToString() }
            }));
        }
Exemplo n.º 2
0
        public bool PutCalendar(CalendarPost calendarPost, long calendarId)
        {
            if (DatabaseManager.GetId($"SELECT * FROM Kalender WHERE Name={Json.SerializeString(calendarPost.name)}") != null)
            {
                return(false);
            }

            return(DatabaseManager.ExecutePut("Kalender", calendarId, calendarPost.ToDictionary()));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public bool AuthorizeOrganizer(long id)
        {
            var organizer = GetOrganizer(id);

            if (organizer == null)
            {
                return(false);
            }

            var user = new NutzerModel().GetUser(id);

            if (Json.GetValue(user, "verifiziert", false) == "0")
            {
                return(false);
            }

            return(DatabaseManager.ExecutePut("Veranstalter", id, new Dictionary <string, string> {
                { "autorisiert", "1" }
            }));
        }
Exemplo n.º 5
0
 public bool PutUser(long id, UserPost userPost)
 {
     return(DatabaseManager.ExecutePut("Nutzerdaten", id, userPost.ToDictionary()));
 }