/// <summary>
        /// Processes the command.
        /// </summary>
        /// <param name="req">Command and Parameters</param>
        /// <returns>
        /// Result of ExecuteNonQuery
        /// </returns>
        public int ProcessCommand(IRequest req)
        {
            SqlCommand sql    = null;
            int        result = 0;

            try
            {
                SqlConnection connectionObject = _connectionHelper.Open() as SqlConnection;

                sql             = new SqlCommand();
                sql.Connection  = connectionObject;
                sql.CommandText = req.Commands;
                sql.CommandType = CommandType.StoredProcedure;

                if (req.RequestParameters != null)
                {
                    foreach (SqlParameter setProp in req.RequestParameters)
                    {
                        sql.Parameters.AddWithValue("@" + setProp.ParameterName, setProp.Value);
                    }
                }
                result = sql.ExecuteNonQuery();
            }
            finally
            {
                if (sql != null)
                {
                    sql.Dispose();
                    sql = null;
                }
            }

            return(result);
        }
 public void Insert(int showId, string showName, DateTime lastAirDate)
 {
     _connection.Open(c => c.Execute("INSERT INTO Subscription (TvShowId, TvShowName, LastAirDate) VALUES (@tvShowId, @tvShowName, @lastAirDate)", new { tvShowId = showId, tvShowName = showName, lastAirDate = lastAirDate }));
 }
 public void SaveEpisode(Episode episode)
 {
     _connection.Open(c => c.Execute("INSERT INTO Episodes (SubscriptionId, SeasonNumber, EpisodeNumber, Title, AirDate) VALUES (@subscriptionId, @seasonNumber, @episodeNumber, @title, @airDate)",
                                     new { subscriptionId = episode.SubscriptionId, seasonNumber = episode.SeasonNumber, episodeNumber = episode.EpisodeNumber, title = episode.Title, airDate = episode.AirDate }));
 }
Example #4
0
 public IEnumerable <Episode> GetToDate(DateTime toDate)
 {
     return(_connection.Open(c => c.Query <Episode>("SELECT * FROM Episodes WHERE AirDate <= @airDate ORDER BY AirDate DESC", new { airDate = toDate })));
 }
 public IEnumerable <int> GetAllSubscriptionIds()
 {
     return(_connection.Open(c => c.Query <int>("SELECT TvShowId FROM Subscription")));
 }