public ActionResult <IEnumerable <string> > PutEvent(EventPost eventPost, string calendar, string uid)
        {
            var calendarId = new KalenderModel().GetCalendarId(calendar);

            if (calendarId == -1)
            {
                return(NotFound());
            }

            if (!auth.CheckIfCalendarPermissions(eventPost, calendarId))
            {
                return(Unauthorized());
            }

            var result = model.PutEvent(calendarId, uid, eventPost);

            if (result)
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
        public ActionResult <IEnumerable <string> > PostEvent(EventPost eventPost, string calendar)
        {
            var calendarId = new KalenderModel().GetCalendarId(calendar);

            if (calendarId == -1)
            {
                return(NotFound());
            }

            if (!auth.CheckIfCalendarPermissions(eventPost, calendarId))
            {
                return(Unauthorized());
            }

            var result = model.PostEvent(calendarId, eventPost);

            if (result != null)
            {
                var path = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/veranstaltungen/{calendar}/{result}";
                return(Created(path, null));
            }
            else
            {
                return(BadRequest());
            }
        }
        public ActionResult <IEnumerable <string> > GetCalendarEvents(string calendar)
        {
            var calendarId = new KalenderModel().GetCalendarId(calendar);

            if (calendarId == -1)
            {
                return(NotFound());
            }

            var query = Request.QueryString.ToUriComponent();

            query = System.Web.HttpUtility.UrlDecode(query);
            var result = model.GetEvents(calendarId, query);

            return(Content(result, "application/json"));
        }
Example #4
0
        private void Termin_Text(DateTime Tag)
        {
            string _Tag          = Tag.ToString("s");
            string _Tag2         = Tag.AddDays(1).ToString("s");
            string _Tag3         = Tag.AddDays(2).ToString("s");
            string _Tag4         = Tag.AddDays(3).ToString("s");
            string _Tag5         = Tag.AddDays(4).ToString("s");
            string _Tag6         = Tag.AddDays(5).ToString("s");
            string _Tag7         = Tag.AddDays(6).ToString("s");
            var    KalenderModel = new KalenderModel();
            var    Termine       = KalenderModel.Kalender.Where(item => item.Termin != null);

            foreach (var termin in Termine)
            {
                Termin_refresh(termin, _Tag, _Tag2, _Tag3, _Tag4, _Tag5, _Tag6, _Tag7);
            }
        }
        public ActionResult <IEnumerable <string> > DeleteEvent(LoginPost loginPost, string calendar, string uid)
        {
            var calendarId = new KalenderModel().GetCalendarId(calendar);

            if (calendarId == -1)
            {
                return(NotFound());
            }

            if (!auth.CheckIfCalendarPermissions(loginPost, calendarId))
            {
                return(Unauthorized());
            }

            if (model.DeleteEvent(calendarId, uid))
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
 public KalenderController()
 {
     model = new KalenderModel();
     auth  = new AuthModel();
 }
Example #7
0
        private void Jahresrechner(DateTime a)
        {
            DateTime b        = a;
            int      Add_days = 7;
            int      Remove_days;
            int      Nummer     = 1;
            bool     Schaltjahr = DateTime.IsLeapYear(b.Year);

            //create DBContext object
            using (var dbCtx = new KalenderModel())
            {
                if (b.DayOfWeek.ToString() == "Monday")
                {
                    Remove_days = 1;
                }
                if (b.DayOfWeek.ToString() == "Tuesday")
                {
                    Remove_days = 2;
                }
                if (b.DayOfWeek.ToString() == "Wednesday")
                {
                    Remove_days = 3;
                }
                if (b.DayOfWeek.ToString() == "Thursday")
                {
                    Remove_days = 4;
                }
                if (b.DayOfWeek.ToString() == "Friday")
                {
                    Remove_days = 5;
                }
                if (b.DayOfWeek.ToString() == "Saturday")
                {
                    Remove_days = 6;
                }
                else
                {
                    Remove_days = 7;
                }

                dbCtx.Database.ExecuteSqlCommand("delete from Kalender");
                while (b.Year == a.Year)
                {
                    //Add Student object into Students DBset
                    var datum = new Datum();
                    datum.Date = b.ToString("s");


                    if (b.DayOfWeek.ToString() == "Saturday")
                    {
                        if (Schaltjahr == false)
                        {
                            if (b.DayOfYear > Add_days)
                            {
                                if (b.DayOfYear <= 151)
                                {
                                    datum.Termin = "Deutsche Liga Spiltag " + Nummer;
                                    Nummer++;
                                }
                            }
                            if (b.DayOfYear <= 364 - (7 + Remove_days))
                            {
                                if (b.DayOfYear >= 256)
                                {
                                    datum.Termin = "Deutsche Liga Spiltag " + Nummer;
                                    Nummer++;
                                }
                            }
                        }
                        if (Schaltjahr == true)
                        {
                            if (b.DayOfYear > Add_days)
                            {
                                if (b.DayOfYear <= 152)
                                {
                                    datum.Termin = "Deutsche Liga Spiltag " + Nummer;
                                    Nummer++;
                                }
                            }
                            if (b.DayOfYear <= 365 - (7 + Remove_days))
                            {
                                if (b.DayOfYear >= 257)
                                {
                                    datum.Termin = "Deutsche Liga Spiltag " + Nummer;
                                    Nummer++;
                                }
                            }
                        }
                    }
                    // call SaveChanges method to save student into database
                    b = b.AddDays(1);
                    dbCtx.Kalender.Add(datum);
                }
                dbCtx.SaveChanges();
            }
        }