public JsonResult SaveEvent(Event e) { var status = false; using (JACEntities dc = new JACEntities()) { if (e.EventId > 0) { //Update the event var v = dc.Events.Where(a => a.EventId == e.EventId).FirstOrDefault(); if (v != null) { v.Description = e.Description; v.ModelNumber = e.ModelNumber; v.CustomerName = e.CustomerName; v.Start = e.Start; v.End = e.End; v.IsFullDay = e.IsFullDay; v.Color = e.Color; } } else { dc.Events.Add(e); } dc.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); }
public JsonResult DeleteEvent(int eventID) { //var eventID= int.Parse(seventID); var status = false; using (JACEntities dc = new JACEntities()) { 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 } }); }