示例#1
0
        public async Task <IActionResult> PutAutor(int id, Autor autor)
        {
            if (id != autor.idautor)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> Put(int id, AutorItem item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> PutAutorModel(AutorModel autorModel)
        {
            try
            {
                var autor = _context.Find <AutorModel>(autorModel.Id);

                if (autor == null)
                {
                    return(NotFound());
                }

                _context.Entry(autor).State = EntityState.Detached;
                autor = autorModel;
                _context.Update(autor);
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                var exception = ex;
                return(BadRequest());
            }
        }