Пример #1
0
        public async Task <IActionResult> PutAmenity(int id, Amenity amenity)
        {
            if (id != amenity.Id)
            {
                return(BadRequest());
            }

            //_context.Entry(amenity).State = EntityState.Modified;

            var updatedAmenity = await _amenity.Update(amenity);

            return(Ok(updatedAmenity));

            //try
            //{
            //    await _context.SaveChangesAsync();
            //}
            //catch (DbUpdateConcurrencyException)
            //{

            //    if (id != amenity.Id)
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}

            //return NoContent();
        }
        public async Task <IActionResult> PutAmenity(int id, Amenity amenity)
        {
            if (id != amenity.Id)
            {
                return(BadRequest());
            }
            await _amenity.Update(amenity);

            return(Ok());
        }
Пример #3
0
        public async Task <IActionResult> PutAmenity(int id, AmenityDTO amenityDto)
        {
            if (id != amenityDto.ID)
            {
                return(BadRequest());
            }
            var updatedAmenity = await _amenity.Update(amenityDto);

            return(Ok(updatedAmenity));
        }