protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); ArticleMapping.Map(modelBuilder.Entity <Article>()); TagMapping.Map(modelBuilder.Entity <Tag>()); ArticleTagMapping.Map(modelBuilder.Entity <ArticleTag>()); }
// // GET: /Article/ public ActionResult Index(int?p) { Pager pager = new Pager(); pager.table = "CMSArticle"; pager.strwhere = "1=1"; pager.PageSize = 2; pager.PageNo = p ?? 1; pager.FieldKey = "ArticleId"; pager.FiledOrder = "ArticleId Desc"; pager = CMSService.SelectAll("Article", pager); List <ArticleDto> list = new List <ArticleDto>(); foreach (DataRow dr in pager.EntityDataTable.Rows) { ArticleDto dto = ArticleMapping.getDTO(dr); list.Add(dto); } pager.Entity = list.AsQueryable(); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.RecordCount = pager.Amount; ViewBag.Message = pager.Amount; return(View(pager.Entity)); }
public ActionResult Edit(ArticleModel model) { ArticleDto dto = new ArticleDto(); DataTable dt = CMSService.SelectOne("Article", "CMSArticle", "ArticleId=" + model.ArticleId); foreach (DataRow dr in dt.Rows) { dto = ArticleMapping.getDTO(dr); dto.ArticleId = model.ArticleId; dto.ArticleTitle = model.ArticleTitle; dto.ArticleContent = model.ArticleContent; dto.ArticleKeywords = model.ArticleKeywords; dto.ArticleDescription = model.ArticleDescription; dto.ArticleCategory = model.ArticleCategory; dto.ArticleAuthor = model.ArticleTitle; dto.ArticleEditor = "系统自动进入"; if (String.IsNullOrEmpty(model.ArticleImg)) { model.ArticleImg = ""; dto.ArticleImg = model.ArticleImg; } dto.ArticleClassic = model.ArticleClassic; dto.ArticleTop = model.ArticleTop; dto.ArticleHot = model.ArticleHot; dto.ArticleTime = System.DateTime.Now; } string JsonString = JsonHelper.JsonSerializerBySingleData(dto); Message msg = CMSService.Update("Article", JsonString); // TODO: Add update logic here return(RedirectToAction("Index")); }
// // GET: /Article/Edit/5 public ActionResult Edit(int id) { ArticleModel model = new ArticleModel(); DataTable dt = CMSService.SelectOne("Article", "CMSArticle", "ArticleId=" + id); foreach (DataRow dr in dt.Rows) { ArticleDto dto = new ArticleDto(); dto = ArticleMapping.getDTO(dr); model.ArticleId = dto.ArticleId; model.ArticleTitle = dto.ArticleTitle; model.ArticleContent = dto.ArticleContent; model.ArticleKeywords = dto.ArticleKeywords; model.ArticleDescription = dto.ArticleDescription; model.ArticleCategory = dto.ArticleCategory; model.ArticleAuthor = dto.ArticleTitle; model.ArticleEditor = dto.ArticleEditor; model.ArticleImg = dto.ArticleImg; model.ArticleClassic = dto.ArticleClassic; model.ArticleTop = dto.ArticleTop; model.ArticleHot = dto.ArticleHot; model.ArticleTime = dto.ArticleTime; } ViewData["Category"] = MyService.GetCategorySelectList("CategoryParentId=1"); return(View(model)); }
public static IMapping CreatMapping(string DtoName) { IMapping Mapping = null; if (DtoName == "User") { Mapping = new UserMapping(); } if (DtoName == "Role") { Mapping = new RoleMapping(); } if (DtoName == "Category") { Mapping = new CategoryMapping(); } if (DtoName == "Article") { Mapping = new ArticleMapping(); } if (DtoName == "Image") { Mapping = new ImageMapping(); } if (DtoName == "Customer") { Mapping = new CustomerMapping(); } if (DtoName == "Tizhi") { Mapping = new TizhiMapping(); } if (DtoName == "Xueya") { Mapping = new XueyaMapping(); } if (DtoName == "Jianyan") { Mapping = new JianyanMapping(); } if (DtoName == "Chufang") { Mapping = new ChufangMapping(); } if (DtoName == "Jixiao") { Mapping = new JixiaoMapping(); } if (DtoName == "Fankui") { Mapping = new FankuiMapping(); } if (DtoName == "Yuyue") { Mapping = new YuyueMapping(); } return(Mapping); }
public void Insert(Guid articleId, string articleNumber, Guid pmbiArticleId, string pmbiArticleNumber) { if (articleId != Guid.Empty && !string.IsNullOrWhiteSpace(articleNumber) && pmbiArticleId != Guid.Empty) { var articleMapping = new ArticleMapping { ArticleId = articleId, ArticleNumber = articleNumber, PmbiArticleId = pmbiArticleId, PmbiArticleNumber = pmbiArticleNumber }; _context.Mappings.Add(articleMapping); _context.SaveChanges(); } }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.HasDefaultSchema("MainDb"); ApplicationUserMapping.Map(builder.Entity <ApplicationUser>()); ArticleArticleTagMapping.Map(builder.Entity <ArticleArticleTag>()); ArticleCommentMapping.Map(builder.Entity <ArticleComment>()); ArticleMapping.Map(builder.Entity <Article>()); ArticleRatingMapping.Map(builder.Entity <ArticleRating>()); ArticleTagMapping.Map(builder.Entity <ArticleTag>()); ContactMapping.Map(builder.Entity <Contact>()); PortfolioMapping.Map(builder.Entity <Portfolio>()); SiteOrderMapping.Map(builder.Entity <SiteOrder>()); SlideShowMapping.Map(builder.Entity <SlideShow>()); }