public IEnumerable <SonnetStatistic> SelectStatisticsAll(SonnetHistoryParams params_)
        {
            IEnumerable <SonnetStatistic> stats;

            using (var sqlConnection = new SqlConnection(_config.GetConnectionString("mssql")))
            {
                if (params_.UserId == "guest")
                {
                    stats = sqlConnection.Query <SonnetStatistic>(SonnetCommand.SELECT_STATS_GLOBAL,
                                                                  new
                    {
                        sonnetId = params_.SonnetId
                    });
                }
                else
                {
                    stats = sqlConnection.Query <SonnetStatistic>(SonnetCommand.SELECT_STATS_ALL,
                                                                  new
                    {
                        userId   = params_.UserId,
                        sonnetId = params_.SonnetId
                    });
                }
            }

            return(stats);
        }
        public IEnumerable <Misspelling> SelectMisspellingsAll(SonnetHistoryParams params_)
        {
            IEnumerable <Misspelling> misspellings;

            using (var sqlConnection = new SqlConnection(_config.GetConnectionString("mssql")))
            {
                if (params_.UserId == "guest")
                {
                    misspellings = sqlConnection.Query <Misspelling>(SonnetCommand.SELECT_MISSPELLINGS_GLOBAL,
                                                                     new
                    {
                        sonnetId = params_.SonnetId
                    });
                }
                else
                {
                    misspellings = sqlConnection.Query <Misspelling>(SonnetCommand.SELECT_MISSPELLINGS_ALL,
                                                                     new
                    {
                        userId   = params_.UserId,
                        sonnetId = params_.SonnetId
                    });
                }
            }

            return(misspellings);
        }
Exemple #3
0
        //public Sonnet GetSonnetById(int? id)
        //{
        //    List<Sonnet> sonnets = (_sonnets != null) ? _sonnets : GetSonnets();

        //    foreach (Sonnet sonnet in sonnets)
        //    {
        //        if (id == sonnet.Id)
        //        {
        //            return sonnet;
        //        }
        //    }

        //    // If sonnet was not found
        //    return null;
        //}

        public SonnetHistoryDto GetSonnetHistory(SonnetHistoryParams params_)
        {
            IEnumerable <Misspelling> misspellings =
                _sonnetSqlDao.SelectMisspellingsAll(params_);
            IEnumerable <SonnetStatistic> statistics =
                _sonnetSqlDao.SelectStatisticsAll(params_);

            var sonnetHistory = new SonnetHistoryDto(statistics, misspellings);

            return(sonnetHistory);
        }
        public IActionResult GetSonnetHistory(SonnetHistoryParams params_)
        {
            SonnetHistoryDto sonnetHistory = _service.GetSonnetHistory(params_);

            return(Ok(sonnetHistory));
        }