public IActionResult Post([FromBody] Piloto value) { if (value == null) { return(BadRequest()); } _context.Pilotos.Add(value); _context.SaveChanges(); return(CreatedAtRoute("GetPiloto", new { dorsal = value.Dorsal }, value)); }
public PilotosController(Formula1Context context) { _context = context; if (_context.Pilotos.Count() == 0) { List <Piloto> pilotos = this.CrearPilotos(); foreach (Piloto p in pilotos) { _context.Pilotos.Add(p); } _context.SaveChanges(); } }
public Formula1Controller(Formula1Context context) { _context = context; if (_context.Monoplazas.Count() == 0) { List <Monoplaza> monolazas = this.CrearMonoplazas(); foreach (Monoplaza m in monolazas) { _context.Monoplazas.Add(m); } _context.SaveChanges(); } }