public bool Create(articleInfoDto entity) { var dbEntity = _mapper.Map <articleInfo>(entity); _baseDB.Set <articleInfo>().Add(dbEntity); return(_baseDB.Commit()); }
public bool Update(articleInfoDto entity) { var dbEntity = _mapper.Map <articleInfo>(entity); _baseDB.Entry <articleInfo>(dbEntity).State = Microsoft.EntityFrameworkCore.EntityState.Modified; UpdateDetails(_baseDB, dbEntity.article_content, dbEntity.article_comments); return(_baseDB.Commit()); }
public bool DeleteArticleInfo(Guid id) { articleInfoDto del = _articleInfoRepository.GetById(id); del.is_del = true; if (del.article_Content != null) { del.article_Content.is_del = true; } if (del.article_Comments != null) { foreach (var item in del.article_Comments) { item.is_del = true; } } return(_articleInfoRepository.Update(del)); }
public bool CreateArticleInfo(articleInfoDto articleInfoDto) { var id = Guid.NewGuid().ToString(); articleInfoDto newArticle = new articleInfoDto { id = id, create_by = "liming", create_date = DateTime.Now, update_by = "liming", update_date = null, is_del = false, title = "title1", type = "编程技术", is_top = false, author = "liming", is_original = true, is_private = false }; articleContentDto articleContent = new articleContentDto { id = Guid.NewGuid().ToString(), article_info_id = id, content = "第一篇博客kjsflkjakfl" }; List <articleCommentDto> articleCommentDto = new List <articleCommentDto> { new articleCommentDto { id = Guid.NewGuid().ToString(), article_info_id = id, name = "张三", email = "*****@*****.**", content = "文章不错呀!!!" } }; newArticle.article_Content = articleContent; newArticle.article_Comments = articleCommentDto; //articleInfoDto.id = id; //if(articleInfoDto.article_Content != null) // articleInfoDto.article_Content.article_info_id = id; //if(articleInfoDto.article_Comments != null) //{ // foreach(var item in articleInfoDto.article_Comments) // { // item.article_info_id = id; // } //} return(_articleInfoRepository.Create(newArticle)); }
public void Post([FromBody] RequestData <articleInfoDto> value) { string type = value.type; articleInfoDto data = value.data; bool result; if (type == "0") { //var input = JsonConvert.DeserializeObject<articleInfoDto>(data.ToString()); result = _articleInfoService.CreateArticleInfo(data); } else if (type == "1") { //var input = JsonConvert.DeserializeObject<articleInfoDto>(data.ToString()); result = _articleInfoService.UpdateArticleInfo(data); } else if (type == "2") { var delId = data.id; result = _articleInfoService.DeleteArticleInfo(Guid.Parse(delId)); } }
public bool UpdateArticleInfo(articleInfoDto articleInfoDto) { return(_articleInfoRepository.Update(articleInfoDto)); }