Exemplo n.º 1
0
        public async Task <IActionResult> PutMediapost([FromRoute] int id, [FromBody] Mediapost mediapost)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mediapost.IdPost)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PostMediapost([FromBody] Mediapost mediapost)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Mediapost.Add(mediapost);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMediapost", new { id = mediapost.IdPost }, mediapost));
        }