Example #1
0
        public IEnumerable<Statistic> Index(string searchText = "")
        {
            IEnumerable<stat> statistics;

            if (!String.IsNullOrEmpty(searchText))
            {
                statistics = context.stats.Where(x => x.name.Contains(searchText)).Take(15);
            }
            else
            {
                statistics = context.stats.Take(15);
            }

            var stats = new List<Statistic>();

            foreach (var item in statistics)
            {
                var s = new Statistic();
                s.Id = item.id;
                s.Name = item.name;
                s.StatisticType = item.stat_type;
                s.Description = item.description;
                stats.Add(s);
            }

            return stats;
        }
Example #2
0
        public IHttpActionResult Show(int id)
        {
            var stat = context.stats.FirstOrDefault(x => x.id == id);
            if (stat == null)
            {
                return NotFound();
            }

            var s = new Statistic();
            s.Id = stat.id;
            s.Name = stat.name;
            s.StatisticType = stat.stat_type;
            s.Description = stat.description;

            return Ok(s);
        }