示例#1
0
        public IActionResult Save(WikiPageEditModel item)
        {
            WikiPageBO bo = new WikiPageBO()
            {
                Title        = item.Title,
                BodyMarkDown = item.Markdown
            };

            WikiPageDTO page = service.Save(bo);

            return(Redirect("/wiki/" + page.Slug));
        }
示例#2
0
        public void BOToDEntity()
        {
            WikiPageBO source = new WikiPageBO()
            {
                BodyMarkDown = "# prova h1",
                Title        = "title prova"
            };

            var result = Mapper.Map <WikiPageEntity>(source);

            Assert.Equal(source.Title, result.Title);
            Assert.Equal("title-prova", result.Slug);
        }
        public WikiPageDTO Save(WikiPageBO item)
        {
            var itemToSave = mapper.Map <WikiPageEntity>(item);
            var count      = db.WikiPages.Where(x => x.Slug == itemToSave.Slug).Count();

            itemToSave.Version = count + 1;
            //if (count == 0)
            //{
            db.WikiPages.Add(itemToSave);
            //}
            //else
            //{
            //    var ent=db.WikiPages.Attach(itemToSave);
            //    ent.State = EntityState.Modified;
            //}
            db.SaveChanges();
            return(mapper.Map <WikiPageDTO>(itemToSave));
        }