Beispiel #1
0
        public async Task <IActionResult> PutStudents(int id, Students students)
        {
            if (id != students.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public void Update(T updated)
        {
            if (_context.Set <T>() == null)
            {
                ErrorMessage = "No Database detected";
                throw new ArgumentNullException(nameof(updated));
            }

            _context.Set <T>().Attach(updated);
            _context.Entry(updated).State = EntityState.Modified;
        }
        public async Task <IActionResult> Put(int id,
                                              Document document)
        {
            if (id != document.DocumentID)
            {
                return(BadRequest());
            }

            _sqlContext.Entry(document).State = EntityState.Modified;

            try
            {
                await _sqlContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
Beispiel #4
0
        public ActionResult <Forum> UpdateForum(int id, ForumDto forumDto)
        {
            var forum = new Forum()
            {
                Id        = id,
                Nome      = forumDto.Nome,
                Descricao = forumDto.Descricao,
                UsuariaId = forumDto.UsuariaId
            };

            _dBContext.Entry(forum).State = EntityState.Modified;
            _dBContext.SaveChangesAsync();

            return(forum);
        }
Beispiel #5
0
        public ActionResult <Comentario> UpdateComentario(int id, ComentarioDto comentarioDto)
        {
            var comentario = new Comentario()
            {
                Id        = id,
                Descricao = comentarioDto.Descricao,
                ForumId   = comentarioDto.ForumId,
                UsuariaId = comentarioDto.UsuariaId
            };

            _dBContext.Entry(comentario).State = EntityState.Modified;
            _dBContext.SaveChangesAsync();

            return(comentario);
        }