public void Post([FromBody] Product product) { Base_testContext ctx = null; try { ctx = new Base_testContext(); } finally { ctx.Dispose(); } }
public IList <Product> Get() { Base_testContext ctx = null; try { ctx = new Base_testContext(); return(ctx.Product.ToList()); } finally { ctx.Dispose(); } }
public IList <Car> Get() { Base_testContext ctx = null; try { ctx = new Base_testContext(); return(ctx.Car.ToList()); } finally { ctx.Dispose(); } }
public void Post([FromBody] Car car) { Base_testContext ctx = null; try { ctx = new Base_testContext(); ctx.Add(car); ctx.SaveChanges(); } finally { ctx.Dispose(); } }
public void Delete(int id) { Base_testContext ctx = null; try { ctx = new Base_testContext(); Car car = ctx.Car.ToList().FirstOrDefault(a => a.Id == id); ctx.Remove(car); ctx.SaveChanges(); } finally { ctx.Dispose(); } }
public Car Get(int id) { Base_testContext ctx = null; try { ctx = new Base_testContext(); Car car = ctx.Car.ToList().FirstOrDefault(a => a.Id == id); return(car); //Car car = ctx.Car.Find(id); //return (car != null) ? car.Name : "404 : Car not found"; } finally { ctx.Dispose(); } }