public void AddNewLocation(Location item) { using (var context = new WorkScheduleContext()) { // Get the new stuff var added = context.Locations.Add(item); context.SaveChanges(); } }
public void UpdateLocation(Location item) { using (var context = new WorkScheduleContext()) { // Edit current location var attached = context.Locations.Attach(item); var existing = context.Entry<Location>(attached); existing.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }