示例#1
0
        public async Task <ActionResult <Livro> > Post(Livro livro)
        {
            _context.Livros.Add(livro);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { id = livro.Id }, livro));
        }
示例#2
0
        public async Task <ActionResult <Editora> > Post(Editora editora)
        {
            _context.Editoras.Add(editora);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { id = editora.Id }, editora));
        }
示例#3
0
        public async Task <IActionResult> PutTema(int id, Tema tema)
        {
            if (id != tema.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#4
0
        public async Task <Editora> CreateEditora(Editora editora)
        {
            _context.Editoras.Add(editora);
            await _context.SaveChangesAsync();

            return(editora);
        }