Exemplo n.º 1
0
        public async Task <IActionResult> UpdatePublication(int id, [FromBody] UpdatePublicationDTO publicationDTO)
        {
            try
            {
                if (id != publicationDTO.IdPublicacion)
                {
                    return(BadRequest());
                }

                if (!_publicationServices.PublicationExists(id))
                {
                    return(NotFound(new { message = $"Publicacion con Id = {id} no existe" }));
                }

                //var publication = _mapper.Map<Publicacione>(publicationDTO);
                await _publicationServices.UpdatePublication(publicationDTO);

                return(StatusCode(StatusCodes.Status204NoContent, publicationDTO));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { message = e.Message }));
            }
        }