Esempio n. 1
0
 private ArticleDomain FillArticle(ArticleDomain article, string key, string title, string content,
                                   string preview, bool isDraft)
 {
     article.Title    = title;
     article.Content  = content;
     article.Modified = DateTime.Now;
     article.Key      = key;
     article.Preview  = preview;
     article.IsDraft  = isDraft;
     return(article);
 }
Esempio n. 2
0
 public ArticleModel(ArticleDomain articleDomain)
 {
     Title          = articleDomain.Title;
     Key            = articleDomain.Key;
     CreatedIso     = articleDomain.Created.ToString("o");
     Created        = articleDomain.Created.ToString("dd MMMM, yyyy");
     ModifiedIso    = articleDomain.Modified.ToString("o");
     Modified       = articleDomain.Modified.ToString("dd MMMM, yyyy");
     PreviewContent = articleDomain.Preview;
     Content        = articleDomain.Content;
     IsDraft        = articleDomain.IsDraft;
 }
Esempio n. 3
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="domain"></param>
        public void Edit(ArticleDomain domain)
        {
            var model = DataProvider.GetAll_Article().FirstOrDefault(x => x.ID == domain.ID);

            if (model == null)
            {
                throw new Exception("文章数据不存在");
            }

            model.ArticleAuthor  = domain.ArticleAuthor;
            model.ArticleContent = domain.ArticleContent;
            model.ArticleDate    = domain.ArticleDate;
            model.ArticleTitle   = domain.ArticleTitle;
            model.ArticleType    = (ArticleTypeEnum)domain.ArticleType;

            DataProvider.Save();
        }
Esempio n. 4
0
 /// <summary>
 /// 增 - 直接添加
 /// </summary>
 /// <param name="domain"></param>
 public void NewCreate(ArticleDomain domain)
 {
     DataProvider.Create(domain.ToDbModel());
 }
Esempio n. 5
0
 public static Article ToDbModel(this ArticleDomain model)
 {
     return(Mapper.Map <Article>(model));
 }