Example #1
0
        public async Task <IActionResult> PutCity([FromRoute] int id, [FromBody] City city)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != city.ID)
            {
                return(BadRequest());
            }

            _context.Entry(city).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(Accepted(city));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public List <Arena> GetArenas([FromRoute] int page = 1)
        {
            var qry = _context.Arenas.OrderBy(p => p.ArenaName);

            foreach (Arena a in qry)
            {
                _context.Entry(a).Navigation("City").Load();
            }

            PagingList <Arena> arenasList;

            if (page != 0)
            {
                arenasList = PagingList.Create(qry, StringsPerPage, page);
            }
            else
            {
                arenasList = PagingList.Create(qry, _context.Arenas.Count() + 1, 1);
            }

            return(arenasList.ToList());
        }