Example #1
0
        public async Task <IActionResult> PutGoesTo(string id, GoesTo goesTo)
        {
            if (id != goesTo.AirportCode)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GoesToExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <GoesTo> > PostGoesTo(GoesTo goesTo)
        {
            _context.GoesTo.Add(goesTo);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (GoesToExists(goesTo.AirportCode))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetGoesTo", new { id = goesTo.AirportCode }, goesTo));
        }