Example #1
0
 /// <summary>
 /// Remove News.
 /// </summary>
 /// <param name="request">The News Request Pivot to remove.</param>
 public void DeleteNews(NewsRequestPivot request)
 {
     if (request?.NewsPivot == null)
     {
         throw new ArgumentNullException(nameof(request));
     }
     Entity.Dataflex.Pro.News.News news = _unitOfWork.NewsRepository.GetById(request.NewsPivot.NewsId);
     _unitOfWork.NewsRepository.Delete(news);
     _unitOfWork.Save();
 }
Example #2
0
 /// <summary>
 /// From News To News Pivot.
 /// </summary>
 /// <param name="news">news TO ASSEMBLE</param>
 /// <returns>NewsPivot result.</returns>
 public static NewsPivot ToPivot(this Entity.Dataflex.Pro.News.News news)
 {
     if (news == null)
     {
         return(null);
     }
     return(new NewsPivot
     {
         NewsId = news.NewsId,
         NewsImage = news.NewsImage,
         NewsDate = news.NewsDate
     });
 }
Example #3
0
        /// <summary>
        /// Change News values.
        /// </summary>
        /// <param name="request">The News Request Pivot to change.</param>
        public void UpdateNews(NewsRequestPivot request)
        {
            if (request?.NewsPivot == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            Entity.Dataflex.Pro.News.News news = _unitOfWork.NewsRepository.GetById(request.NewsPivot.NewsId);
            news.NewsDate = request.NewsPivot.NewsDate;
            if (request.NewsPivot.NewsImage != null)
            {
                news.NewsImage = request.NewsPivot.NewsImage;
            }
            _unitOfWork.Save();
        }
Example #4
0
        /// <summary>
        /// Create new News.
        /// </summary>
        /// <param name="request">The News Request Pivot to add.</param>
        /// <returns>News Response Pivot created.</returns>
        public NewsResponsePivot CreateNews(NewsRequestPivot request)
        {
            if (request?.NewsPivot == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            Entity.Dataflex.Pro.News.News news = request.NewsPivot.ToEntity();
            _unitOfWork.NewsRepository.Insert(news);
            _unitOfWork.Save();
            return(new NewsResponsePivot()
            {
                NewsPivot = news.ToPivot()
            });
        }