public ArticleDto AddArticle(ArticleDto article) { ArticleEntity articleToAdd = Mapper.Map <ArticleEntity>(article); articleToAdd.ArticleCreationDate = DateTime.Now; articleToAdd.ArticleUserdId = 1; dbContext.Articles.Add(articleToAdd); dbContext.SaveChanges(); return(article); }
public CommentDto AddComment(CommentDto comment, int articleId) { CommentEntity commentToAdd = Mapper.Map <CommentEntity>(comment); commentToAdd.ArticleId = articleId; commentToAdd.CommentCreationDate = DateTime.Now; dbContext.Comments.Add(commentToAdd); dbContext.SaveChanges(); return(comment); }