Пример #1
0
 //edit with sproc
 public void Edit(Dvd dvd)
 {
     using (var connection = ADODatabaseConnection.GetOpenConnection())
     {
         connection.Execute(
             "Edit",
             dvd,
             commandType: CommandType.StoredProcedure
             );
     }
 }
Пример #2
0
        //add with sproc
        public Dvd Add(Dvd dvd)
        {
            using (var connection = ADODatabaseConnection.GetOpenConnection())
            {
                connection.Execute(
                    "Add",
                    dvd,
                    commandType: CommandType.StoredProcedure
                    );
            }

            return(dvd);
        }
Пример #3
0
        //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);
        }
Пример #4
0
        //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
                    );
            }
        }
Пример #5
0
        //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);
        }
Пример #6
0
        //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);
        }
Пример #7
0
        //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);
        }