/// <summary>
        /// Gets the averages of a team's season schedule
        /// </summary>
        /// <param name="teamName">The name of the selected team</param>
        /// <param name="seasonID">The ID of the selected season</param>
        /// <returns>The result of the stored procedure execution</returns>
        public ObjectResult <GetTeamSeasonScheduleAverages_Result> GetTeamSeasonScheduleAverages(string teamName,
                                                                                                 int?seasonID)
        {
            try
            {
                return(_dbContext.GetTeamSeasonScheduleAverages(teamName, seasonID));
            }
            catch (ArgumentException ex)
            {
                _log.Error(
                    $"Argument exception in StoredProcedureRepository.GetTeamSeasonScheduleAverages: {ex.Message}");

                throw;
            }
            catch (InvalidOperationException ex)
            {
                _log.Error(
                    $"Invalid operation in StoredProcedureRepository.GetTeamSeasonScheduleAverages: {ex.Message}");

                throw;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);

                throw;
            }
        }
Ejemplo n.º 2
0
        public static void SetUpFakeTeamSeasonScheduleAverages(this ProFootballEntities dbContext,
                                                               IEnumerable <GetTeamSeasonScheduleAverages_Result> teamSeasonScheduleAverages = null)
        {
            var fakeObjectResult = A.Fake <ObjectResult <GetTeamSeasonScheduleAverages_Result> >(d =>
                                                                                                 d.Implements(typeof(IEnumerable <GetTeamSeasonScheduleAverages_Result>)));

            // Setup all IEnumerable methods using what you have from "teamSeasonScheduleAverages"
            A.CallTo(() => (fakeObjectResult as IEnumerable <GetTeamSeasonScheduleAverages_Result>).GetEnumerator())
            .Returns(teamSeasonScheduleAverages.GetEnumerator());

            // Do the wiring between DbContext and ObjectResult
            A.CallTo(() => dbContext.GetTeamSeasonScheduleAverages(A <string> .Ignored, A <int> .Ignored))
            .Returns(fakeObjectResult);
        }
        /// <summary>
        /// Gets the averages of a team's season schedule
        /// </summary>
        /// <param name="dbContext">An instance of the ProFootballEntities class</param>
        /// <param name="teamName">The name of the selected team</param>
        /// <param name="seasonID">The ID of the selected season</param>
        /// <returns>The result of the stored procedure execution</returns>
        public ObjectResult <GetTeamSeasonScheduleAverages_Result> GetTeamSeasonScheduleAverages(
            ProFootballEntities dbContext, string teamName, int?seasonID)
        {
            ObjectResult <GetTeamSeasonScheduleAverages_Result> retVal = null;

            try
            {
                retVal = dbContext.GetTeamSeasonScheduleAverages(teamName, seasonID);
            }
            catch (ArgumentException ex)
            {
                _log.Error(
                    "Argument exception in StoredProcedureRepository.GetTeamSeasonScheduleAverages: " + ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                _log.Error("Invalid operation in StoredProcedureRepository.GetTeamSeasonScheduleAverages: " +
                           ex.Message);
            }

            return(retVal);
        }