//edit with sproc public void Edit(Dvd dvd) { using (var connection = ADODatabaseConnection.GetOpenConnection()) { connection.Execute( "Edit", dvd, commandType: CommandType.StoredProcedure ); } }
//add with sproc public Dvd Add(Dvd dvd) { using (var connection = ADODatabaseConnection.GetOpenConnection()) { connection.Execute( "Add", dvd, commandType: CommandType.StoredProcedure ); } return(dvd); }
//get all Dvds with sproc public List <Dvd> GetAll() { List <Dvd> dvds; using (var connection = ADODatabaseConnection.GetOpenConnection()) { dvds = connection.Query <Dvd>( "GetAll", commandType: CommandType.StoredProcedure ).ToList(); } return(dvds); }
//delete with sproc public void Delete(int id) { using (var connection = ADODatabaseConnection.GetOpenConnection()) { var parameters = new DynamicParameters(); parameters.Add("@DvdId", id); connection.Execute( "Delete", parameters, commandType: CommandType.StoredProcedure ); } }
//sproc takes id, populate to list public Dvd GetById(int id) { Dvd dvdToReturn; using (var connection = ADODatabaseConnection.GetOpenConnection()) { var parameters = new DynamicParameters(); parameters.Add("@DvdId", id); dvdToReturn = connection.Query <Dvd>( "GetById", parameters, commandType: CommandType.StoredProcedure ).SingleOrDefault(); } return(dvdToReturn); }
//sproc takes director name, pupulates to list public List <Dvd> GetByDirector(string directorName) { List <Dvd> dvds; using (var connection = ADODatabaseConnection.GetOpenConnection()) { var parameters = new DynamicParameters(); parameters.Add("@Director", directorName); dvds = connection.Query <Dvd>( "GetByDirector", parameters, commandType: CommandType.StoredProcedure ).ToList(); } return(dvds); }
//sproc takes year, populate to list public List <Dvd> GetByReleaseYear(int releaseYear) { List <Dvd> dvds; var parameters = new DynamicParameters(); parameters.Add("@ReleaseYear", releaseYear); using (var connection = ADODatabaseConnection.GetOpenConnection()) { dvds = connection.Query <Dvd>( "GetByReleaseYear", parameters, commandType: CommandType.StoredProcedure ).ToList(); } return(dvds); }