Exemplo n.º 1
0
 public JsonResult GetAppointments()
 {
     // Return all the records from the Calendar in JSON format
     using (KnEntitiesDB dc = new KnEntitiesDB())
     {
         var v = dc.CalendarEvents.OrderBy(a => a.StartDay).ToList();
         return(new JsonResult {
             Data = v, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Exemplo n.º 2
0
        public JsonResult CalendarDeleteAppointment(int eventID)
        {
            bool status = false;

            using (KnEntitiesDB dc = new KnEntitiesDB())
            {
                var v = dc.CalendarEvents.Where(a => a.CalendarID.Equals(eventID)).FirstOrDefault();
                if (v != null)
                {
                    dc.CalendarEvents.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemplo n.º 3
0
        public JsonResult CalendarSaveAppointment(CalendarEvent evt)
        {
            bool status = false;

            using (KnEntitiesDB dc = new KnEntitiesDB())
            {
                if (evt.EndDay != null && evt.StartDay.TimeOfDay == new TimeSpan(0, 0, 0) &&
                    evt.EndDay.TimeOfDay == new TimeSpan(0, 0, 0))
                {
                    evt.isFullDay = true;
                }
                else
                {
                    evt.isFullDay = false;
                }

                if (evt.CalendarID > 0)
                {
                    var v = dc.CalendarEvents.Where(a => a.CalendarID.Equals(evt.CalendarID)).FirstOrDefault();
                    if (v != null)
                    {
                        v.CalendarTitle = evt.CalendarTitle;
                        v.CalendarDesc  = evt.CalendarDesc;
                        v.StartDay      = evt.StartDay;
                        v.EndDay        = evt.EndDay;
                        v.isFullDay     = evt.isFullDay;
                    }
                }
                else
                {
                    dc.CalendarEvents.Add(evt);
                }

                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }