Exemplo n.º 1
0
        public async Task <ActionResult <BirdPhoto> > PostBirdPhoto(BirdPhoto birdPhoto)
        {
            _context.BirdPhotos.Add(birdPhoto);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBirdPhoto", new { id = birdPhoto.Id }, birdPhoto));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutBirdPhoto(int id, BirdPhoto birdPhoto)
        {
            if (id != birdPhoto.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }