public async Task <IActionResult> ReadInAgregator(NewsGetDTO newsWithCommentsDTO) { var newsWithDetails = await _newsService.GetNewsBiId(newsWithCommentsDTO.Id); var commentsEnt = await _commentService.FindAllCommentsForNews(newsWithCommentsDTO.Id); var comentsDto = _mapper.Map <IEnumerable <CommentDto> >(commentsEnt); newsWithDetails.Comments = comentsDto; return(View(newsWithDetails)); }
public async Task <IActionResult> DeleteNews(NewsGetDTO newsGetDTO) { var news = _unitOfWork.News.GetByCondition(x => x.Id.Equals(newsGetDTO.Id), false).SingleOrDefault(); if (news is null) { BadRequest("Can't find news!"); } try { _unitOfWork.News.Remove(news); } catch (Exception ex) { Log.Error($"something went wrong. Details: {ex.Message}"); } await _unitOfWork.SaveAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Details(NewsGetDTO newsGetDTO) { var newsWithDetails = await _newsService.GetNewsBiId(newsGetDTO.Id); return(View(newsWithDetails)); }