Ejemplo n.º 1
0
        public async Task <ActionResult <DoggoFriend> > PostDoggoFriend(DoggoFriend doggoFriend)
        {
            _context.doggoFriend.Add(doggoFriend);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDoggoFriend", new { id = doggoFriend.DoggoFriendId }, doggoFriend));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutDoggoFriend(int id, DoggoFriend doggoFriend)
        {
            if (id != doggoFriend.DoggoFriendId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }