internal static void CriarPassageiro(CriarPassageiroViewModel viewModel) { string conexao = @"Data Source=tcp:testeaplicativo.database.windows.net,1433;Initial Catalog=TesteAplicativoBd;User [email protected];Password=087615Baldin;"; using (SqlConnection conn = new SqlConnection(conexao)) { string comando = $"INSERT INTO Passageiros (Nome,DataNascimento,CPF,Sexo)" + $"VALUES('{viewModel.Nome}','{viewModel.DataNascimento.ToString("yyyy-MM-dd")}','{viewModel.CPF}','{viewModel.Sexo}')"; using (SqlCommand cmd = new SqlCommand(comando, conn)) { conn.Open(); var teste = cmd.ExecuteScalar(); } } }
public IActionResult Criar(CriarPassageiroViewModel viewModel) { PassageiroData.CriarPassageiro(viewModel); return(Redirect("Index")); }