示例#1
0
        public ActionResult Details(PageDataViewModel page)
        {
            if (string.IsNullOrEmpty(page.TextBody) || string.IsNullOrEmpty(page.HtmlBody))
                return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Missing required data.");

            Mapper.CreateMap<PageDataViewModel, Page>();
            var updatedPage = Mapper.Map(page, _pageService.GetByID(page.Id));
            updatedPage.UpdatedDate = DateTime.UtcNow;

            _pageService.Update(updatedPage);

            return View(page);
        }
示例#2
0
        public ActionResult Create(PageDataViewModel page)
        {
            if (string.IsNullOrEmpty(page.TextBody) || string.IsNullOrEmpty(page.HtmlBody))
                return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "Missing required data.");

            Mapper.CreateMap<PageDataViewModel, Page>();
            var newPage = Mapper.Map<PageDataViewModel, Page>(page);
            newPage.CreatedDate = DateTime.UtcNow;
            newPage.UpdatedDate = DateTime.UtcNow;

            _pageService.Insert(newPage);

            return RedirectToAction("Details", new { id = newPage.ID }); ;
        }
示例#3
0
        public ActionResult Details(int id)
        {
            var page = _pageService.GetByID(id);
            var pageViewModel = new PageDataViewModel()
                {
                    Id = page.ID,
                    Title = page.Title,
                    HtmlBody = page.HtmlBody,
                    TextBody = page.TextBody,
                    IsPublished = page.IsPublished,
                    CreatedDate = page.CreatedDate.ToString("f"),
                    UpdatedDate = page.UpdatedDate.ToString("f")
                };

            return View(pageViewModel);
        }