Esempio n. 1
0
        public long AddParticipant(Dictionary <string, string> booking)
        {
            var d      = booking;
            var e      = Json.GetKvpValue(d, "veranstaltung", false);
            var userId = Json.GetKvpValue(d, "nutzerId", false);

            var result = DatabaseManager.ExecutePost("Teilnehmer", new Dictionary <string, string>
            {
                { "Veranstaltung", e },
                { "Nutzer", userId },
            });

            new VeranstaltungenModel().UpdateParticipantCount(Convert.ToInt64(e));
            return(result);
        }
Esempio n. 2
0
        public bool PostBooking(BookingPost bookingPost, string eventUid)
        {
            var eventId = GetEventId(eventUid);

            bookingPost.veranstaltung = eventId;
            if (!CheckIfEventCanBeBooked(Convert.ToInt64(eventId)))
            {
                return(false);
            }

            var userId = new NutzerModel().PostUser(bookingPost.ToUserPost());
            var d      = bookingPost.ToDictionary();

            d.Add("Nutzer", userId.ToString());
            return(DatabaseManager.ExecutePost("Buchungen", d) != -1);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public bool PostCalendarOrganizer(long calendarId, CalendarPost calendarPost)
        {
            var organizerId = calendarPost.veranstalter;

            if (DatabaseManager.CountResults($"SELECT * FROM Veranstalter WHERE Id={organizerId} AND Autorisiert=1") != 1)
            {
                return(false);
            }

            if (DatabaseManager.CountResults($"SELECT * FROM Kalenderberechtigte WHERE Veranstalter={organizerId} AND Kalender={calendarId}") == 1)
            {
                return(false);
            }

            DatabaseManager.ExecutePost("Kalenderberechtigte", calendarPost.ToAuthorizationDictionary(calendarId));
            return(true);
        }
        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);
            }
        }
Esempio n. 6
0
        public long PostUser(UserPost userPost)
        {
            if (userPost == null)
            {
                return(-1);
            }
            var d = userPost.ToDictionary();

            d.Add("Verifiziert", "0");
            var id = DatabaseManager.ExecutePost("Nutzerdaten", d);

            if (id <= 0)
            {
                return(-1);
            }

            new EmailverifizierungenModel().AddNewCode(id, 12);
            return(id);
        }
Esempio n. 7
0
        public long PostOrganizer(OrganizerPost organizerPost)
        {
            var id = new NutzerModel().PostUser(organizerPost.ToUserPost());

            if (id == -1)
            {
                return(-1);
            }

            var d = organizerPost.ToDictionary();

            d.Add("Autorisiert", "0");
            d.Add("id", id.ToString());

            var result = DatabaseManager.ExecutePost("Veranstalter", d);



            return(result);
        }
        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);
            }
        }
Esempio n. 9
0
        public bool PostAdmin(long organizerId)
        {
            var organizer = new VeranstalterModel().GetOrganizer(organizerId);

            if (organizer != null && GetAdmin(organizerId) == null)
            {
                if (Json.GetKvpValue(organizer, "verifiziert", false) == "0" || Json.GetKvpValue(organizer, "autorisiert", false) == "0")
                {
                    return(false);
                }

                var adminPost = new Dictionary <string, string> {
                    { "id", organizerId.ToString() }
                };
                return(DatabaseManager.ExecutePost("Admins", adminPost) == organizerId);
            }
            else
            {
                return(false);
            }
        }