Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }