public void addEmployee(Employee emp) { using (GSQ2_Garry_TestContext ctx = new GSQ2_Garry_TestContext()) { ctx.Employee.Add(emp); ctx.SaveChanges(); } }
public void addNewCarNewModel(Car car) { using (GSQ2_Garry_TestContext ctx = new GSQ2_Garry_TestContext()) { ctx.Car.Add(car); // ctx.Entry(car.CarFeatures.) ctx.SaveChanges(); } }
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(); } }