示例#1
0
        public async Task <IActionResult> Posthotel_representatives([FromBody] hotel_representatives hotel_representatives)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.hotel_representatives.Add(hotel_representatives);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Gethotel_representatives", new { id = hotel_representatives.id }, hotel_representatives));
        }
示例#2
0
        public async Task <IActionResult> Puthotel_representatives([FromRoute] int id, [FromBody] hotel_representatives hotel_representatives)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }