Ejemplo n.º 1
0
        private static void BuildPage(PageViewModel model, IUser user, Page page, Int32 mid, Int32 flag) {
            page.Title = model.Title;
            page.Summary = model.Summary;
            page.Status = model.Status;
            page.Thumbnail = model.Thumbnail;
            page.Content.Content = model.Content;
            page.User = user;
            page.BelongTo = mid;
            page.BelongType = flag;

            if (model.Status == CommonStatus.Published)
                page.PublishAt = DateTime.UtcNow;
        }
Ejemplo n.º 2
0
        public ActionResult EditorPost(PageViewModel model, ContentProviderType cpt, Int32 mid, Int32 flag) {
            var user = _authenticationService.GetAuthenticatedUser();

            Page page = null;
            if (model.Id > 0) {
                page = _pageService.Get(model.Id);
                BuildPage(model, user, page, mid, flag);
                page.UpdateAt = DateTime.UtcNow;
            } else {
                if (cpt == ContentProviderType.Content)
                    page = _pageService.Get(m => m.BelongTo == mid && m.BelongType == flag);

                if (page != null) {
                    BuildPage(model, user, page, mid, flag);
                    page.UpdateAt = DateTime.UtcNow;
                } else {
                    page = Mapper.Map<PageViewModel, Page>(model);
                    var content = Mapper.Map<PageViewModel, EntityContent>(model);
                    page.Content = content;
                    BuildPage(model, user, page, mid, flag);
                    _pageService.Add(page);
                }
            }
            if (cpt == ContentProviderType.Content)
                return RedirectToAction("Editor", new {
                    mid,
                    flag,
                    cpt,
                    page.Id
                });

            return RedirectToAction("Index", new {
                mid,
                flag
            });
        }