예제 #1
0
        public async Task <IActionResult> PutUnidad(int id, Indic indic)
        {
            if (id != indic.REGISTRO)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <ActionResult <Indic> > PostUnidad(Indic indic)
        {
            _context.Indic.Add(indic);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (UnidadExists(indic.REGISTRO))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetUnidad", new { id = indic.REGISTRO }, indic));
        }