コード例 #1
0
        public async Task <IActionResult> UpdateSpecialty(int id, SpecialtyDto specialty)
        {
            if (id != specialty.Id)
            {
                return(BadRequest());
            }

            var specialtyUpdated = await _context.Specialties.FindAsync(id);

            if (specialtyUpdated == null)
            {
                return(NotFound());
            }

            specialtyUpdated.Name = specialty.Name;

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

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

            return(NoContent());
        }
コード例 #2
0
ファイル: VetsController.cs プロジェクト: gokalpi/PetClinic
        public async Task <IActionResult> UpdateVet(int id, VetDto vet)
        {
            if (id != vet.Id)
            {
                return(BadRequest());
            }

            var vetUpdated = await _context.Vets.FindAsync(id);

            if (vetUpdated == null)
            {
                return(NotFound());
            }

            _mapper.Map(vet, vetUpdated);

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

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

            return(NoContent());
        }
コード例 #3
0
ファイル: OwnersController.cs プロジェクト: gokalpi/PetClinic
        public async Task <IActionResult> UpdateOwner(int id, OwnerDto owner)
        {
            if (id != owner.Id)
            {
                return(BadRequest());
            }

            var ownerUpdated = await _context.Owners.FindAsync(id);

            if (ownerUpdated == null)
            {
                return(NotFound());
            }

            _mapper.Map(owner, ownerUpdated);

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

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

            return(NoContent());
        }