Ejemplo n.º 1
0
        public void UpdateDetails(IBaseDB baseDB, articleContent content, ICollection <articleComment> comments)
        {
            var articleContent = baseDB.Table <articleContent>().FirstOrDefault(x => x.id == content.id);

            if (articleContent == null)
            {
                baseDB.Set <articleContent>().Add(content);
            }
            else
            {
                baseDB.Entry <articleContent>(content).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            }

            foreach (var item in comments)
            {
                var articleComment = baseDB.Table <articleComment>().FirstOrDefault(x => x.id == item.id);
                if (articleComment == null)
                {
                    baseDB.Set <articleComment>().Add(articleComment);
                }
                else
                {
                    baseDB.Entry <articleComment>(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                }
            }
        }
Ejemplo n.º 2
0
        public articleInfoDto GetById(Guid id)
        {
            var dbEntity = _baseDB.Table <articleInfo>()
                           .FirstOrDefault(x => x.id == id && x.is_del == false);

            if (dbEntity != null)
            {
                LoadDetails(_baseDB, dbEntity);
            }

            return(dbEntity != null?_mapper.Map <articleInfoDto>(dbEntity) : null);
        }
Ejemplo n.º 3
0
 public void LoadDetails(IBaseDB baseDB, articleInfo articleinfo)
 {
     articleinfo.article_content  = baseDB.Table <articleContent>().FirstOrDefault(x => x.article_info_id == articleinfo.id);
     articleinfo.article_comments = baseDB.Table <articleComment>().Where(x => x.article_info_id == articleinfo.id).ToList();
 }