Exemple #1
0
        public object Get(Movies request)
        {
            var response = new MoviesResponse();

            DbFactory.Exec(dbCmd =>
            {
                if (request.Id != null)
                {
                    var movie = dbCmd.GetByIdOrDefault <Movie>(request.Id);
                    if (movie != null)
                    {
                        response.Movies.Add(movie);
                    }
                }
                else
                {
                    response.Movies = dbCmd.Select <Movie>();
                }
            });

            return(response);
        }
        public object Get(Movies request)
        {
            var response = new MoviesResponse();

            using (var dbConn = ConnectionFactory.OpenDbConnection())
                using (var dbCmd = dbConn.CreateCommand())
                {
                    if (request.Id != null)
                    {
                        var movie = dbCmd.GetByIdOrDefault <Movie>(request.Id);
                        if (movie != null)
                        {
                            response.Movies.Add(movie);
                        }
                    }
                    else
                    {
                        response.Movies = dbCmd.Select <Movie>();
                    }
                }

            return(response);
        }