Пример #1
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);
        }
Пример #2
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);
        }