public ActionResult Delete([FromBody] Models.Request.AutomovilEditRequest model) { using (Models.CrudVanillaJsContext db = new Models.CrudVanillaJsContext()) { Models.Automovil oAutomovil = db.Automovil.Find(model.Id); db.Automovil.Remove(oAutomovil); db.SaveChanges(); } return(Ok()); }
public ActionResult Put([FromBody] Models.Request.AutomovilEditRequest model) { using (Models.CrudVanillaJsContext db = new Models.CrudVanillaJsContext()) { Models.Automovil oAutomovil = db.Automovil.Find(model.Id); oAutomovil.Marca = model.Marca; oAutomovil.Valor = model.Valor; db.Entry(oAutomovil).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); } return(Ok()); }
public ActionResult Post([FromBody] Models.Request.AutomovilRequest model) { using (Models.CrudVanillaJsContext db = new Models.CrudVanillaJsContext()) { Models.Automovil oAutomovil = new Models.Automovil(); oAutomovil.Marca = model.Marca; oAutomovil.Valor = model.Valor; db.Automovil.Add(oAutomovil); db.SaveChanges(); } return(Ok()); }