Esempio n. 1
0
        public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutBookingRecord([FromRoute] int id, [FromBody] BookingRecord bookingRecord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bookingRecord.BookingId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <ActionResult> Put(int?id, [FromBody] HotelRoom newhr)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            if (id != newhr.RoomId)
            {
                return(NotFound());
            }

            _context.Entry(newhr).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }