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

            using (Calendar_databaseEntities dc = new Calendar_databaseEntities())
            {
                if (e.EventID > 0)
                {
                    var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();

                    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 }
            });
        }
Beispiel #2
0
 public JsonResult GetEvents()
 {
     using (Calendar_databaseEntities dc = new Calendar_databaseEntities())
     {
         var events = dc.Events.ToList();
         return(new JsonResult {
             Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Beispiel #3
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

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