コード例 #1
0
ファイル: FarmController.cs プロジェクト: RodTGG/MyFarm
        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;
                }
            }
        }
コード例 #2
0
ファイル: AnimalController.cs プロジェクト: RodTGG/MyFarm
        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;
                }
            }
        }