Пример #1
0
        public ActionResult Create(int?parentId)
        {
            IViewModelBase viewModel = null;
            //AddViewBag(o);
            var viewTemplate = db.ViewTemplates.Where(x => x.Name.Equals("_BlogList")).FirstOrDefault();

            viewModel = new BlogListContentCreateOrEditViewModel()
            {
                ParentId       = parentId,
                ViewTemplateId = viewTemplate.Id,
                ViewTemplate   = viewTemplate
            };
            return(Edit <PageContent>("CreateOrEdit", viewModel));
        }
Пример #2
0
        public ActionResult Edit(int?id, string language)
        {
            var            o         = db.Set <PageContent>().Where(x => x.Id == id).FirstOrDefault();
            IViewModelBase viewModel = null;

            if (o != null)
            {
                //AddViewBag(o);
                viewModel = new BlogListContentCreateOrEditViewModel()
                {
                    Id             = o.Id,
                    ParentId       = o.PageId,
                    Index          = o.Index,
                    ViewTemplate   = o.ViewTemplate,
                    ViewTemplateId = o.ViewTemplateId
                };
            }
            return(Edit <PageContent>("CreateOrEdit", viewModel));
        }
Пример #3
0
        public ActionResult Edit(BlogListContentCreateOrEditViewModel vmObj)
        {
            var parent = db.Pages.Where(x => x.Id == vmObj.ParentId).FirstOrDefault();

            if (parent == null)
            {
                return(new EmptyResult());
            }
            return(UpdateRelatedObjectUsingViewModel <Page, PageContent>(parent.Id, vmObj, (p) =>
            {
                var pageContent = db.PageContents.Where(x => x.Id == vmObj.Id).FirstOrDefault();

                if (pageContent != null)
                {
                    pageContent.Index = vmObj.Index;
                    //PageContent.ViewName = vmObj.ViewName;
                    pageContent.ViewTemplateId = vmObj.ViewTemplateId;
                }
                return pageContent;
            }));
        }
Пример #4
0
        public ActionResult Create(BlogListContentCreateOrEditViewModel vmObj)
        {
            var parent = db.Pages.Where(x => x.Id == vmObj.ParentId).FirstOrDefault();

            if (parent == null)
            {
                return(new EmptyResult());
            }
            return(CreateRelatedObjectUsingViewModel <Page, PageContent>(parent.Id, vmObj, (p) =>
            {
                //Convert the ViewModel to DB Object (Model)
                var pageContent = new PageContent()
                {
                    Index = vmObj.Index,
                    //ViewName = vmObj.ViewName,
                    ViewTemplateId = vmObj.ViewTemplateId,
                    PageId = vmObj.ParentId,
                    PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("BlogList")).FirstOrDefault()
                };
                db.PageContents.Add(pageContent);
                return pageContent;
            }));
        }