Beispiel #1
0
        public ActionResult ListEvents(int id)
        {
            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == id).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            var events = this.service.GetEventsFromCalendar(id);

            return(Json(events, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult ListEventsInTimePeriod(int calendarId, DateTime start, DateTime end)
        {
            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == calendarId).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            var events = this.service.GetEventsFromCalendar(calendarId).Where(e => e.BeginTime <= end && e.EndTime >= start);

            return(Json(events, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public ActionResult Details(int id)
        {
            var domain = this.service.Get(id);

            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == domain.CalendarID).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            var model = DomainToModel.Map(domain);

            return(View(model));
        }
Beispiel #4
0
        public ActionResult Update(EventViewModel ev)
        {
            var sanitizer = new HtmlSanitizer();

            if (!String.IsNullOrWhiteSpace(ev.Title))
            {
                ev.Title = sanitizer.Sanitize(ev.Title);
            }
            if (!String.IsNullOrWhiteSpace(ev.Description))
            {
                ev.Description = sanitizer.Sanitize(ev.Description);
            }

            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == ev.CalendarID).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            if (ModelState.IsValid)
            {
                if (ev.Repeat)
                {
                    this.occurService.Create(new Domain.Aggregate.Occurrence.Occurrence()
                    {
                        Count = 1
                    });
                    var last = this.occurService.GetOccurrences.OrderByDescending(o => o.ID).Take(1).Single();
                    ev.OccurrenceID = last.ID;
                }
                if (!ev.Repeat && ev.OccurrenceID.HasValue)
                {
                    int id = ev.OccurrenceID.Value;
                    this.occurService.Delete(id);
                }
                if (ev.Notifications.Count > 0)
                {
                    ev.Notifications[0].EventID = this.service.GetEvents.LastOrDefault().ID;
                    this.notifyService.Create(DomainToModel.Map(ev.Notifications[0]));
                }
                int calendarID = ev.CalendarID;
                var domain     = DomainToModel.Map(ev);
                this.service.Update(domain);
                return(RedirectToAction("Index", new { id = calendarID }));
            }
            return(View(ev));
        }
Beispiel #5
0
        public ActionResult Update(int id)
        {
            var ev = this.service.Get(id);

            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == ev.CalendarID).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            var model = DomainToModel.Map(ev);

            InitDropDownList(model);
            return(View(model));
        }
Beispiel #6
0
        public ActionResult Create(int calendarID)
        {
            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == calendarID).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            EventViewModel model = new EventViewModel();

            InitDropDownList(model);
            model.BeginTime  = DateTime.Now;
            model.EndTime    = DateTime.Now;
            model.CalendarID = calendarID;
            return(View(model));
        }
Beispiel #7
0
        public ActionResult Delete(EventViewModel ev)
        {
            Web.Calendar cal = this.calService.GetUserCalendars().Where(c => c.ID == ev.CalendarID).SingleOrDefault();

            if (cal == null)
            {
                return(new HttpStatusCodeResult(403));
            }

            int calendarID = ev.CalendarID;
            var notify     = this.notifyService.GetNotificationFromEvent(ev.ID);

            if (notify != null)
            {
                this.notifyService.Delete(notify.ID);
            }
            if (ev.OccurrenceID != null)
            {
                int id = ev.OccurrenceID.Value;
                this.occurService.Delete(id);
            }
            this.service.Delete(ev.ID);
            return(RedirectToAction("Index", new { id = calendarID }));
        }