public ActionResult Create([Bind(Include = "ID,Tipo,Preco")] Veiculo veiculo)
        {
            if (ModelState.IsValid)
            {
                db.Veiculos.Add(veiculo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(veiculo));
        }
Beispiel #2
0
        public IActionResult Create([FromBody] Veiculo item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.veiculo.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetVeiculo", new { placa = item.placa }, item));
        }
 public void AtualizarVeiculo(VeiculoDB veiculo)
 {
     _dbContext.Entry(veiculo).State = EntityState.Modified;
     _dbContext.SaveChanges();
 }
Beispiel #4
0
 public void AtualizarMarca(Marca marca)
 {
     _dbContext.Entry(marca).State = EntityState.Modified;
     _dbContext.SaveChanges();
 }
 public void AtualizarModelo(ModeloDB modelo)
 {
     _dbContext.Entry(modelo).State = EntityState.Modified;
     _dbContext.SaveChanges();
 }
Beispiel #6
0
 protected void Update <ModelType>(ModelType model) where ModelType : ModelBase
 {
     _context.Entry(model).State = EntityState.Modified;
     _context.SaveChanges();
 }