private void SaveToDB_Update(Guid eventId) { using (var context = new WoodlandLifeEntities()) { var _event = context.Events.First(e => e.EventID == eventId); _event.Date = oDate.Date.Value.Value; _event.Title = oTitle.Text; _event.Content = oContentHtml.Text; context.SaveChanges(); } }
protected void oDelete_Click(object sender, EventArgs e) { if (EventId.HasValue) { using (var context = new WoodlandLifeEntities()) { context.DeleteObject(context.Events.First(ev => ev.EventID == EventId.Value)); context.SaveChanges(); } } //Reload the page to refresh data. ReloadPage(); }
private void SaveToDB_New() { using (var context = new WoodlandLifeEntities()) { var _event = new Event(); _event.EventID = Guid.NewGuid(); _event.Date = oDate.Date.Value.Value; _event.Title = oTitle.Text; _event.Content = oContentHtml.Text; context.AddToEvents(_event); context.SaveChanges(); } }