3
I am creating a small project in without Entity Framework and I have a question at the time of passing an object as parameter, it is correct to pass the same object that calls the method as parameter?
Code:
[HttpPost]
public ActionResult Edit(Movie movie)
{
movie.EditMovie(movie);
return RedirectToAction("Filmes");
}
This is the method that will receive the object
public void EditMovie(Movie film)
{
Conn conexao = new Conn();
string strUpdate = "UPDATE tbMovie SET movieName=@nameMovie, movieYear=@yearMovie WHERE movieId=@idMovie";
MySqlCommand cmd = new MySqlCommand(strUpdate, conexao.ConectionData());
cmd.Parameters.Add("@idMovie", MySqlDbType.VarChar).Value = film.MovieId;
cmd.Parameters.Add("@nameMovie", MySqlDbType.VarChar).Value = film.MovieName;
cmd.Parameters.Add("@yearMovie", MySqlDbType.VarChar).Value = film.MovieYear;
cmd.ExecuteNonQuery();
conexao.ConectionData();
}