public async Task <IActionResult> PutAutor([FromRoute] int id, [FromBody] Autor autor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != autor.AutorId)
            {
                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 <ActionResult> Edit([Bind(Include = "Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Entry(category).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(category));
        }
Пример #3
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Text,Asked,ViewCount,AnswerCount,VoteCount")] Question question)
        {
            if (ModelState.IsValid)
            {
                db.Entry(question).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(question));
        }
Пример #4
0
 public void Remove(TEntity obj)
 {
     _context.Entry(obj).State = EntityState.Deleted;
     _context.SaveChanges();
 }
Пример #5
0
 public void Alterar(TClass obj)
 {
     db.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     db.SaveChanges();
 }
Пример #6
0
 public IActionResult Edit(Post Post)
 {
     _db.Entry(Post).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }