Beispiel #1
0
        public int CreateArticle(CreateArticleInputModel inputModel)
        {
            Article newArticle = new Article();
            newArticle.Title = inputModel.Title;
            newArticle.Summary = inputModel.Summary;
            newArticle.Content = inputModel.Content;
            newArticle.DateAdded = DateTime.Now;
            newArticle.DisplayOrder = inputModel.DisplayOrder;

            this.Data.Articles.Add(newArticle);
            this.Data.SaveChanges();

            Image defaultImage = new Image
            {
                ImageExtension = "jpg",
                ImagePath = "Content\\images\\noimage\\no-image",
                IsPrimary = true,
                DateAdded = DateTime.Now
            };

            newArticle.Image = defaultImage;
            this.Data.SaveChanges();

            return newArticle.Id;
        }
Beispiel #2
0
        private CreateArticleInputModel MapPageInputModel(Article dbArticle)
        {
            CreateArticleInputModel model = new CreateArticleInputModel();
            model.Id = dbArticle.Id;
            model.Title = dbArticle.Title;
            model.Summary = dbArticle.Summary;
            model.Content = dbArticle.Content;
            model.DisplayOrder = dbArticle.DisplayOrder;
            model.Image = dbArticle.Image;

            return model;
        }
Beispiel #3
0
        private ArticleViewModel MapArticleViewModel(Article dbArticle)
        {
            ArticleViewModel model = new ArticleViewModel();
            model.Id = dbArticle.Id;
            model.Title = dbArticle.Title;
            model.Image = dbArticle.Image;
            model.DateAdded = dbArticle.DateAdded;
            model.Summary = dbArticle.Summary;
            model.Content = dbArticle.Content;

            return model;
        }