Ejemplo n.º 1
0
        public IActionResult Get(string moniker)
        {
            try
            {
                var talks = Mapper.Map <IEnumerable <TalkViewModel> >(_repo.GetTalks(moniker));

                // Update Vote Counts
                var counts = _repo.GetTalkCounts(moniker);
                foreach (var t in talks)
                {
                    var result = counts.Where(c => c.Item1.Id == t.Id).FirstOrDefault();
                    if (result != null)
                    {
                        t.Votes = result.Item2;
                    }
                }

                return(Ok(talks));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to get talks: {0}", ex);
            }

            return(BadRequest("Couldn't load talks."));
        }