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); }
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; }
/// <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(); }
/// <summary> /// 增 - 直接添加 /// </summary> /// <param name="domain"></param> public void NewCreate(ArticleDomain domain) { DataProvider.Create(domain.ToDbModel()); }
public static Article ToDbModel(this ArticleDomain model) { return(Mapper.Map <Article>(model)); }