コード例 #1
0
        public async Task <IActionResult> PutRolEstablecimiento(int id, RolEstablecimiento rolEstablecimiento)
        {
            if (id != rolEstablecimiento.RolId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <RolEstablecimiento> > PostRolEstablecimiento(RolEstablecimiento rolEstablecimiento)
        {
            _context.RolEstablecimiento.Add(rolEstablecimiento);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (RolEstablecimientoExists(rolEstablecimiento.RolId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetRolEstablecimiento", new { id = rolEstablecimiento.RolId }, rolEstablecimiento));
        }