Exemplo n.º 1
0
        public async Task <IActionResult> UpdateFarm(int id, Farm farm)
        {
            if (id != farm.FarmId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();

                return(new JsonResult(farm));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FarmExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateAnimal(int id, Animal animal)
        {
            if (id != animal.AnimalId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();

                return(new JsonResult(animal));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AnimalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }