public ActionResult AddEvent(AddEventModel new_event)
        {
            ECalendar cal = null;
            if (0 != new_event.calendarId && null != this._db)
            {
                cal = this._db.SingleOrDefault<ECalendar>(new_event.calendarId);
            }
            if (!ModelState.IsValid)
            {
                TempData["StatusNewEvent"] = "Invalid";
                return RedirectToAction("Index", new { id = cal.Id });

                //ViewData["calendar"] = cal;
                //return PartialView("Index");
            }
            TempData["StatusNewEvent"] = "Valid";
            CalendarEntry entry = new CalendarEntry()
                {
                    allDay = new_event.allday,
                    calendarId = new_event.calendarId,
                    description = new_event.description,
                    title = new_event.title,
                    start = new_event.start,
                    locationId = new_event.selectedLocation
                };
            if (new_event.start > new_event.end)
            {
                entry.end = null;
            }
            else
            {
                entry.end = new_event.end;
            }

            this._db.Insert(entry);

            return RedirectToAction("Index", new { id = cal.Id });
        }
 public ActionResult EditEventForm(EditEventModel e)
 {
     List<EventLocation> locations = this._db.Query<EventLocation>("SELECT * FROM ec_locations").ToList();
     locations.Insert(0, new EventLocation() { LocationName = "No Location", Id = 0 });
     SelectList list = new SelectList(locations, "Id", "LocationName", e.selectedLocation);
     e.locations = list;
     if (!ModelState.IsValid)
     {
         TempData["StatusEditEvent"] = "Invalid";
         return PartialView("EditEventForm",e);
     }
     TempData["StatusEditEvent"] = "Valid";
     CalendarEntry entry = new CalendarEntry()
     {
         allDay = e.allday,
         calendarId = e.calendarId,
         description = e.description,
         title = e.title,
         end = e.end,
         start = e.start,
         Id = e.Id,
         locationId = e.selectedLocation
     };
     this._db.Update(entry);
     return PartialView("EditEventForm",e);
 }
 public ActionResult DeleteEvent(CalendarEntry entry)
 {
     this._db.Delete<CalendarEntry>(entry.Id);
     return RedirectToAction("ShowEvents", new { id = entry.calendarId });
 }