public void Update(History history) { var newHistory = context.History.Include("Driver").Include("User").First(h => h.Id == history.Id); newHistory.Driver = history.Driver; newHistory.User = history.User; newHistory.DepatureAddress = history.DepatureAddress; newHistory.DestinationAddress = history.DestinationAddress; newHistory.StartTime = history.StartTime; newHistory.FinishTime = history.FinishTime; context.Entry<History>(newHistory).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public void Delete(History history) { var delHistory = context.History.Include("Driver").Include("User").First(h => h.Id == history.Id); context.History.Remove(delHistory); context.SaveChanges(); }