예제 #1
0
        public int UpdateNews(int id, UpdatedNewsDto updatedNewsDto)
        {
            var news = GetNewsEntity(id);

            news.Title       = updatedNewsDto.Title ?? news.Title;
            news.Description = updatedNewsDto.Description ?? news.Description;
            news.UserId      = updatedNewsDto.UserId ?? news.UserId;

            _db.News.Update(news);
            _db.SaveChanges();
            return(news.Id);
        }
예제 #2
0
 public ActionResult <IdDto> UpdateNews(int id, [FromBody] UpdatedNewsDto updatedNewsDto)
 {
     return(new OkObjectResult(new { Id = _newsService.UpdateNews(id, updatedNewsDto) }));
 }