public ActionResult Create([Bind(Include = "Id,Nome,Placa")] CarroEntity carroEntity) { if (ModelState.IsValid) { db.CarroEntities.Add(carroEntity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(carroEntity)); }
public void Adicionar(Veiculo model) { var result = validator.Validate(model); if (!result.IsValid) { throw new ArgumentException($"Validações falharam. {String.Join(",", result.Errors)}"); } dbContext.Veiculos.Add(model); dbContext.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Nome,Cpf,Dt_Nascminento")] MotoristaEntity motoristaEntity) { if (ModelState.IsValid) { db.MotoristaEntities.Add(motoristaEntity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(motoristaEntity)); }
public void Adicionar(Manobrista manobrista) { var result = validator.Validate(manobrista); if (!result.IsValid) { throw new ArgumentException($"Validações falharam. {String.Join(",", result.Errors)}"); } dbContext.Manobristas.Add(manobrista); dbContext.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Responsavel,Carro,IdMotorista")] ResponsavelEntity responsavelEntity) { int id = int.Parse(responsavelEntity.Responsavel); if (ModelState.IsValid) { responsavelEntity.IdMotorista = db.MotoristaEntities.Find(id).Id; responsavelEntity.Responsavel = db.MotoristaEntities.Find(id).Nome; db.ResponsavelEntities.Add(responsavelEntity); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(responsavelEntity)); }
public void Adicionar(ManobristaVeiculo model) { dbContext.ManobristasVeiculos.Add(model); dbContext.SaveChanges(); }