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);
        }
 public long GetCalendarId(string uid)
 {
     if (GetEvent(uid) == null)
     {
         return(-1);
     }
     else
     {
         return(Convert.ToInt64(CalendarManager.GetOrganizerCommonName(uid)));
     }
 }
Exemple #4
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 DeleteCalendar(long calendarId)
 {
     if (!DatabaseManager.ExecuteDelete("Kalender", calendarId))
     {
         return(false);
     }
     else
     {
         DatabaseManager.ExecuteNonQuery($"DELETE FROM Veranstaltungen WHERE Kalender = {calendarId}");
         return(CalendarManager.DeleteCalendar(calendarId));
     }
 }
        public bool DeleteEvent(long calendarId, string uid)
        {
            var id = calendarId;

            if (CalendarManager.GetEvent(uid).Organizer.CommonName != id.ToString())
            {
                return(false);
            }

            DatabaseManager.ExecuteNonQuery($"DELETE FROM Veranstaltungen WHERE Uid=\"{uid}\"");
            CalendarManager.DeleteEvent(Convert.ToInt64(id), uid);
            return(true);
        }
        public string GetEvent(string uid)
        {
            var result = CalendarManager.GetEventAsJsonObject(uid);

            if (result == null)
            {
                return(null);
            }

            var command = $"SELECT * FROM Veranstaltungen WHERE Veranstaltungen.Uid=\"{uid}\"";

            using (var reader = DatabaseManager.ExecuteReader(command))
            {
                result = Json.MergeObjects(new string[] { result, DatabaseManager.ReadFirstAsJsonObject(GetEventKeyTableDictionary(), reader, null) }, true);
            }

            return(result);
        }
        public string PostEvent(long id, EventPost eventPost)
        {
            eventPost.kalender = id;
            var uid = CalendarManager.AddEvent(eventPost, id.ToString());
            var d   = eventPost.ToDictionary();

            d["Uid"]            = uid;
            d["Teilnehmerzahl"] = "0";
            var result = DatabaseManager.ExecutePost("Veranstaltungen", d);

            if (result > 0)
            {
                return(uid);
            }
            else
            {
                return(null);
            }
        }
        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 #11
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 #12
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 string GetEvents(long calendarId, string queryString)
        {
            var es = CalendarManager.GetEvents(calendarId);

            return(GetEvents(es, queryString));
        }
        public bool PutEvent(long calendarId, string uid, EventPost eventPost)
        {
            var result = CalendarManager.EditEvent(calendarId, eventPost, uid);

            return(result);
        }
        public string GetEvents(string queryString)
        {
            var es = CalendarManager.GetEvents();

            return(GetEvents(es, queryString));
        }
        public void WipeUnnecessaryData()
        {
            var dateTime = CalendarManager.GetDateTime(DateTime.Now);

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