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

            using (EventsDBEntities1 dc = new EventsDBEntities1())
            {
                if (e.EventId > 0)
                {
                    //Update the event
                    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;
                    }
                }
                else
                {
                    dc.Events.Add(e);
                }
                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Example #2
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (EventsDBEntities1 dc = new EventsDBEntities1())
            {
                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 }
            });
        }