public JsonResult SaveArticle(List <t_article> data) { DateTime Now = DateTime.Now; t_article _article = new t_article(); _article.create_date = Now; _article.article_id = 0; _article.article_name = data[0].article_name; _article.article_category = data[0].article_category; _article.image = data[0].image; _article.is_active = data[0].is_active; _article.article_content_short = data[0].article_content_short; _article.article_content = data[0].article_content; _article.language = data[0].language; _article.valid_from = data[0].valid_from; _article.valid_to = data[0].valid_to; _article.author = data[0].author; db.t_article.Add(_article); db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); }
public static Article ConvertTo(this t_article entity) { return(new Article() { Id = entity.id, Author = entity.author, CategoryId = entity.category, Title = entity.title, Keys = entity.keys, Summary = entity.summary, ImgUrl = entity.img_url, Contents = entity.contents, ReadCount = entity.read_count, CommentCount = entity.comment_count, CreateTime = entity.create_time, UpdateTime = entity.update_time, Recommend = entity.recommend == 1 ? true : false, }); }