Exemple #1
0
        private bool ProcessBooking(Dictionary <string, string> booking)
        {
            var d    = booking;
            var type = Json.GetKvpValue(d, "buchungstyp", false);

            if (Json.GetKvpValue(d, "verifiziert", false) == "0")
            {
                return(false);
            }

            var eventId  = Json.GetKvpValue(d, "veranstaltung", false);
            var e        = new VeranstaltungenModel().GetEvent(Convert.ToInt64(eventId));
            var deadline = Json.GetKvpValue(e, "anmeldefrist", false);

            if (Convert.ToInt64(deadline) < Convert.ToInt64(CalendarManager.GetDateTime(DateTime.Now)))
            {
                return(false);
            }

            if (type == "0")
            {
                return(new TeilnehmerModel().AddParticipant(d) != -1);
            }

            if (type == "1")
            {
                return(new TeilnehmerModel().DeleteParticipant(d));
            }

            return(false);
        }
Exemple #2
0
        public bool CheckIfEventCanBeBooked(long eventId)
        {
            var dt                       = CalendarManager.GetDateTime(DateTime.Now);
            var SelectById               = $"SELECT * FROM Veranstaltungen WHERE Id={eventId}";
            var FilterByTimeLimit        = $"Anmeldefrist>{dt}";
            var FilterByParticipantLimit = $"(Teilnehmerzahl < Teilnehmerlimit OR Teilnehmerlimit < 0)";

            return(DatabaseManager.CountResults($"{SelectById} AND {FilterByTimeLimit} AND {FilterByParticipantLimit}") == 1);
        }
Exemple #3
0
        public Dictionary <string, string> ToDictionary()
        {
            var result = new Dictionary <string, string> {
                { "Veranstaltung", veranstaltung },
                { "Buchungstyp", buchungstyp.ToString() },
                { "Zeitstempel", CalendarManager.GetDateTime(DateTime.Now) }
            };



            return(result);
        }
        public bool ProcessVerification(string code)
        {
            var dateTime = CalendarManager.GetDateTime(DateTime.Now);
            var reader   = DatabaseManager.ExecuteReader($"SELECT * FROM Emailverifizierungen WHERE Code=\"{code}\" AND Zeitfrist>={dateTime}");
            var r        = DatabaseManager.ReadFirstAsJsonObject(new Dictionary <string, string> {
                { "nutzer", "Nutzer" }
            }, reader, null);
            var id = Convert.ToInt64(Json.GetKvpValue(r, "nutzer", false));

            if (new NutzerModel().VerifyUser(id) > 0)
            {
                DeleteVerificationCode(GetVerificationCodeId(code));
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public string AddNewCode(long userId, double hours)
        {
            var code     = GenerateUniqueCode();
            var dt       = DateTime.Now.AddHours(hours);
            var dateTime = CalendarManager.GetDateTime(dt);
            var dict     = new Dictionary <string, string> {
                { "Nutzer", userId.ToString() },
                { "Zeitfrist", dateTime },
                { "Code", code },
            };

            if (DatabaseManager.ExecutePost("Emailverifizierungen", dict) > 0)
            {
                return(code);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        public void SaveData()
        {
            if (!Directory.Exists("Archiv"))
            {
                Directory.CreateDirectory("Archiv");
            }

            var directory = $"Archiv\\{CalendarManager.GetDateTime(DateTime.Now)}";

            Directory.CreateDirectory(directory);
            if (File.Exists(CalendarManager.Path))
            {
                File.Copy(CalendarManager.Path, $"{directory}\\{CalendarManager.Path}");
            }

            if (File.Exists(DatabaseManager.Path))
            {
                File.Copy(DatabaseManager.Path, $"{directory}\\{DatabaseManager.Path}");
            }
        }
Exemple #7
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());
        }
        public void WipeUnnecessaryData()
        {
            var dateTime = CalendarManager.GetDateTime(DateTime.Now);

            DatabaseManager.ExecuteNonQuery($"DELETE FROM Emailverifizierungen WHERE Zeitfrist<={dateTime}");
        }