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()));
        }
Beispiel #2
0
        public bool DeleteParticipant(Dictionary <string, string> booking)
        {
            var d      = booking;
            var e      = Json.GetKvpValue(d, "veranstaltung", false);
            var userId = Json.GetKvpValue(d, "nutzer", false);
            var id     = DatabaseManager.GetId($"SELECT * FROM Teilnehmer WHERE Veranstaltung={e} AND Id={userId}");
            var result = DatabaseManager.ExecuteDelete("Teilnehmer", Convert.ToInt64(id));

            new VeranstaltungenModel().UpdateParticipantCount(Convert.ToInt64(e));
            return(result);
        }
        public long GetVerificationCodeId(string code)
        {
            var id = DatabaseManager.GetId($"SELECT * FROM Emailverifizierungen WHERE Code=\"{code}\"");

            if (id != null)
            {
                return(Convert.ToInt64(id));
            }
            else
            {
                return(-1);
            }
        }
        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);
        }
Beispiel #5
0
        public long GetLoggedInOrganizer(LoginData loginData)
        {
            var email    = Json.SerializeString(loginData.ml);
            var passwort = Json.SerializeString(loginData.pw);
            var result   = DatabaseManager.GetId($"SELECT * FROM Veranstalter INNER JOIN Nutzerdaten ON Veranstalter.Id=Nutzerdaten.Id " +
                                                 $"WHERE Email={email} AND Passwort={passwort} AND Verifiziert=1 AND Autorisiert=1");

            if (result != null)
            {
                return(Convert.ToInt64(result));
            }
            else
            {
                return(-1);
            }
        }
        public long PostCalendar(CalendarPost calendarPost)
        {
            if (new VeranstalterModel().GetOrganizer(calendarPost.veranstalter) == null)
            {
                return(-1);
            }
            if (DatabaseManager.GetId($"SELECT * FROM Kalender WHERE Name={Json.SerializeString(calendarPost.name)}") != null)
            {
                return(-1);
            }

            var id = DatabaseManager.ExecutePost("Kalender", calendarPost.ToDictionary());

            DatabaseManager.ExecutePost("Kalenderberechtigte", calendarPost.ToAuthorizationDictionary(id));
            return(id);
        }
        public bool DeleteCalendarOrganizer(long calendarId, long organizerId)
        {
            var c = DatabaseManager.CountResults($"SELECT * FROM Kalenderberechtigte WHERE Kalender={calendarId}");

            if (c <= 1)
            {
                return(false);
            }
            else
            {
                var id = DatabaseManager.GetId($"SELECT * FROM Kalenderberechtigte WHERE Kalender={calendarId} AND Veranstalter={organizerId}");
                if (id == null)
                {
                    return(false);
                }
                else
                {
                    return(DatabaseManager.ExecuteDelete("Kalenderberechtigte", Convert.ToInt64(id)));
                }
            }
        }
Beispiel #8
0
 public string GetEventId(string eventUid)
 {
     eventUid = Json.DeserializeString(eventUid);
     return(DatabaseManager.GetId($"SELECT * FROM Veranstaltungen WHERE Uid=\"{eventUid}\""));
 }
Beispiel #9
0
        public string GetParticipants(string eventUid)
        {
            var id = Convert.ToInt64(DatabaseManager.GetId($"SELECT * FROM Veranstaltungen WHERE Uid=\"{eventUid}\""));

            return(GetParticipants(id));
        }