示例#1
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);
        }
示例#2
0
 public bool DeleteCalendar(long calendarId)
 {
     if (!DatabaseManager.ExecuteDelete("Kalender", calendarId))
     {
         return(false);
     }
     else
     {
         DatabaseManager.ExecuteNonQuery($"DELETE FROM Veranstaltungen WHERE Kalender = {calendarId}");
         return(CalendarManager.DeleteCalendar(calendarId));
     }
 }
示例#3
0
        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)));
                }
            }
        }
示例#4
0
        public void WipeUnnecessaryData()
        {
            var bookings = Json.DeserializeArray(GetBookingsAsArray());
            var bookingEventDictionary = new Dictionary <string, string>();
            var eventIds       = new List <string>();
            var outdatedEvents = new List <string>();

            foreach (var booking in bookings)
            {
                var o         = Json.DeserializeObject(booking);
                var bookingId = Json.GetKvpValue(o, "id", false);
                var eventId   = Json.GetKvpValue(o, "veranstaltung", false);
                bookingEventDictionary.Add(bookingId, eventId);
                if (!eventIds.Contains(eventId))
                {
                    eventIds.Add(eventId);
                }
            }

            var v       = new VeranstaltungenModel();
            var timeNow = Convert.ToInt64(CalendarManager.GetDateTime(DateTime.Now));

            foreach (var eventId in eventIds)
            {
                var e = v.GetEvent(Convert.ToInt64(eventId));
                if (e == null)
                {
                    outdatedEvents.Add(eventId);
                    continue;
                }

                var deadline = Convert.ToInt64(Json.GetKvpValue(e, "anmeldefrist", false));
                if (deadline < timeNow)
                {
                    outdatedEvents.Add(eventId);
                }
            }

            DatabaseManager.ExecuteDelete("Buchungen", "Veranstaltung", outdatedEvents.ToArray());
        }
示例#5
0
 public bool DeleteAdmin(long adminId)
 {
     return(DatabaseManager.ExecuteDelete("Admins", adminId));
 }
示例#6
0
 public bool DeleteOrganizer(long id)
 {
     return(DatabaseManager.ExecuteDelete("Veranstalter", id));
 }
 public bool DeleteVerificationCode(long id)
 {
     return(DatabaseManager.ExecuteDelete("Emailverifizierungen", id));
 }
示例#8
0
 public bool DeleteBooking(long bookingId)
 {
     return(DatabaseManager.ExecuteDelete("Buchungen", bookingId));
 }
示例#9
0
        public bool WipeUnnecessaryData()
        {
            var usedDataList      = new List <long>();
            var toBeDeletedIdList = new List <long>();

            var organizers = DatabaseManager.ReadAsJsonArray(new Dictionary <string, string> {
                { "id", "Id" }
            }, DatabaseManager.ExecuteReader("SELECT * FROM Veranstalter"));

            foreach (var o in Json.DeserializeArray(organizers))
            {
                var id = Json.GetKvpValue(o, "id", false);
                if (id != null)
                {
                    usedDataList.Add(Convert.ToInt64(id));
                }
            }

            var bookings = DatabaseManager.ReadAsJsonArray(new Dictionary <string, string> {
                { "id", "Id" }
            }, DatabaseManager.ExecuteReader("SELECT * FROM Buchungen"));

            foreach (var b in Json.DeserializeArray(bookings))
            {
                var id = Json.GetKvpValue(b, "nutzer", false);
                if (id != null)
                {
                    usedDataList.Add(Convert.ToInt64(id));
                }
            }

            var codes = DatabaseManager.ReadAsJsonArray(new Dictionary <string, string> {
                { "id", "Id" }
            }, DatabaseManager.ExecuteReader("SELECT * FROM Emailverifizierungen"));

            foreach (var c in Json.DeserializeArray(codes))
            {
                var id = Json.GetKvpValue(c, "nutzer", false);
                if (id != null)
                {
                    usedDataList.Add(Convert.ToInt64(id));
                }
            }

            var users = DatabaseManager.ReadAsJsonArray(new Dictionary <string, string> {
                { "id", "Id" }
            }, DatabaseManager.ExecuteReader("SELECT * FROM Nutzerdaten"));

            foreach (var u in Json.DeserializeArray(users))
            {
                var id = Json.GetKvpValue(u, "id", false);
                if (id != null)
                {
                    var i = Convert.ToInt64(id);
                    if (!usedDataList.Contains(i))
                    {
                        toBeDeletedIdList.Add(i);
                    }
                }
            }

            return(DatabaseManager.ExecuteDelete("Nutzerdaten", toBeDeletedIdList.ToArray()));
        }