Beispiel #1
0
        public JsonResult SaveEvent(Event e)
        {
            var status = false;

            using (CalendarDatabaseEntities dc = new CalendarDatabaseEntities())
            {
                if (e.EventID > 0)
                {
                    //Update the event
                    var v = dc.Events.FirstOrDefault(a => a.EventID == e.EventID);
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsFullDay   = e.IsFullDay;
                        v.ThemeColor  = e.ThemeColor;
                    }
                }
                else
                {
                    dc.Events.Add(e);
                }
                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
 public void WriteAllEventsFromListToDatabase()
 {
     for (int i = 0; i < CalendarWithBase.Model.Calendar.getInstance().dayEventsList.Count; i++)
     {
         DayEvents dayEventInDataBase = new DayEvents()
         {
             username         = this.username,
             eventDescription = ((DayEvent)CalendarWithBase.Model.Calendar.getInstance().dayEventsList[i]).GetDescription(),
             startTime        = ((DayEvent)CalendarWithBase.Model.Calendar.getInstance().dayEventsList[i]).GetStartTime(),
             endTime          = ((DayEvent)CalendarWithBase.Model.Calendar.getInstance().dayEventsList[i]).GetEndTime()
         };
         databaseContext.DayEvents.AddObject(dayEventInDataBase);
     }
     databaseContext.SaveChanges();
 }
Beispiel #3
0
        public JsonResult DeleteEvent(int eventId)
        {
            var status = false;

            using (CalendarDatabaseEntities dc = new CalendarDatabaseEntities())
            {
                var v = dc.Events.FirstOrDefault(a => a.EventID == eventId);
                if (v != null)
                {
                    dc.Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }