Beispiel #1
0
        public void Post([FromBody] Car car)
        {
            Base_testContext ctx = null;

            try
            {
                ctx = new Base_testContext();
                ctx.Add(car);
                ctx.SaveChanges();
            }
            finally
            {
                ctx.Dispose();
            }
        }
Beispiel #2
0
        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();
            }
        }