public void updateEmployee(Employee emp) { using (GSQ2_Garry_TestContext ctx = new GSQ2_Garry_TestContext()) { ctx.Entry(emp).State = Microsoft.EntityFrameworkCore.EntityState.Modified; ctx.Entry(emp.EmployeeNavigation).State = Microsoft.EntityFrameworkCore.EntityState.Modified; ctx.SaveChanges(); } }
public void sellCar(Car car, Customer cust, decimal totalPrice, string notes) { using (GSQ2_Garry_TestContext ctx = new GSQ2_Garry_TestContext()) { CarSaleRecord sale = new CarSaleRecord(); sale.Customer = cust; sale.Car = car; sale.PuchaseDate = DateTime.Now; sale.TotalPaidPrice = totalPrice; sale.Note = notes; ctx.Entry(sale.Car).State = EntityState.Unchanged; ctx.CarSaleRecord.Add(sale); ctx.SaveChanges(); } }