当前位置: 首页>>代码示例>>C#>>正文


C# Page.Update方法代码示例

本文整理汇总了C#中Page.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Page.Update方法的具体用法?C# Page.Update怎么用?C# Page.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page.Update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetStatus

        public ActionResult SetStatus(string id, string status) {
            return null;
            Guid pageID = new Guid(id);
            ActionResult result;
            var pg = new Page(pageID);//_cmsRepository.GetPage(pageID);

            if (status == "Publish") {
                //pull the page
                pg.Status = PublishStatus.Published;
                pg.Update(User.Identity.Name);
                return RedirectToAction("Index", "Home", new { slug = pg.Slug });
            } else if (status == "Take Offline") {
                //offline
                pg.Status = PublishStatus.Offline;
                pg.Update(User.Identity.Name);
                return RedirectToAction("Edit", "Page", new { id = pg.PageID.ToString() });

            } else if (status == "Delete") {
                pg.Delete();
                return RedirectToAction("Index", "Home");
            } else {
                return RedirectToAction("Edit", "Page", new { id = pg.PageID.ToString() });

            }


        }
开发者ID:christattum,项目名称:Kona,代码行数:27,代码来源:PageController.cs

示例2: Edit

        public ActionResult Edit(Page page) {
            this.SiteData = KonaSite.GetSite("/");
            this.CurrentCustomer = Customer.GetExistingOrCreate(this.GetCommerceUserName());

            if (page != null) {
                page.ModifiedBy = User.Identity.Name;
                page.ModifiedOn = DateTime.Now;
                page.LanguageCode = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
                page.Slug = page.Title.CreateSlug();

                page.Update(User.Identity.Name);

                return View("EditPage", page);
            } else {
                return RedirectToAction("Create");
            }
        }
开发者ID:christattum,项目名称:Kona,代码行数:17,代码来源:PageController.cs

示例3: AccountListsManage_Save

        void AccountListsManage_Save(object sender, EventArgs e)
        {
            string title = core.Http.Form["title"];
            string slug = core.Http.Form["title"];
            string listAbstract = core.Http.Form["abstract"];
            short type = core.Functions.FormShort("type", 1);
            long listId = core.Functions.FormLong("id", 0);

            // new
            if (listId == 0)
            {
                try
                {
                    List newList = List.Create(core, title, ref slug, listAbstract, type);

                    SetRedirectUri(BuildUri("lists"));
                    core.Display.ShowMessage("List Created", "You have created a new list");
                    return;
                }
                catch (ListTypeNotValidException)
                {
                    core.Display.ShowMessage("List Error", "You submitted invalid information. Go back and try again.");
                    return;
                }
                catch (ListSlugNotUniqueException)
                {
                    core.Display.ShowMessage("List Error", "You have already created a list with the same name, go back and give another name.");
                    return;
                }
            }

            // edit
            if (listId > 0)
            {
                try
                {
                    List list = new List(core, session.LoggedInMember, listId);

                    string oldSlug = list.Path;

                    list.Title = title;
                    list.Abstract = listAbstract;
                    list.Type = type;

                    try
                    {
                        list.Update();

                        // Update page
                        try
                        {
                            Page listPage = new Page(core, core.Session.LoggedInMember, oldSlug, "lists");

                            listPage.Title = list.Title;
                            listPage.Slug = list.Path;

                            listPage.Update();
                        }
                        catch (PageNotFoundException)
                        {
                            Page listPage;
                            try
                            {
                                listPage = new Page(core, core.Session.LoggedInMember, "lists");
                            }
                            catch (PageNotFoundException)
                            {
                                string listSlug = "lists";
                                try
                                {
                                    listPage = Page.Create(core, core.Session.LoggedInMember, "Lists", ref listSlug, 0, "", PageStatus.PageList, 0, Classifications.None);
                                }
                                catch (PageSlugNotUniqueException)
                                {
                                    throw new Exception("Cannot create lists slug.");
                                }
                            }
                            slug = list.Path;
                            Page page = Page.Create(core, core.Session.LoggedInMember, title, ref slug, listPage.Id, "", PageStatus.PageList, 0, Classifications.None);
                        }

                        SetRedirectUri(core.Hyperlink.BuildAccountSubModuleUri(ModuleKey, "lists"));
                        core.Display.ShowMessage("List Saved", "You have saved the list");
                        return;
                    }
                    catch (UnauthorisedToUpdateItemException)
                    {
                        DisplayGenericError();
                        return;
                    }
                    catch (RecordNotUniqueException)
                    {
                        core.Display.ShowMessage("List Error", "You have already created a list with the same name, go back and give another name.");
                        return;
                    }
                }
                catch (InvalidListException)
                {
                    DisplayGenericError();
                    return;
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:AccountListsManage.cs

示例4: AccountPagesWrite_Save

        void AccountPagesWrite_Save(object sender, EventArgs e)
        {
            string slug = core.Http.Form["slug"];
            string title = core.Http.Form["title"];
            string pageBody = core.Http.Form["post"];
            long parent = 0;
            long pageId = 0;
            PageStatus status = PageStatus.Publish;

            if (core.Http.Form["publish"] != null)
            {
                status = PageStatus.Publish;
            }

            if (core.Http.Form["save"] != null)
            {
                status = PageStatus.Draft;
            }

            pageId = core.Functions.FormLong("id", 0);
            parent = core.Functions.FormLong("page-parent", 0);

            try
            {
                if (pageId > 0)
                {
                    try
                    {
                        Page page = new Page(core, Owner, pageId);

                        page.Update(core, Owner, title, ref slug, parent, pageBody, status, core.Functions.GetLicenseId(), core.Functions.GetClassification());
                    }
                    catch (PageNotFoundException)
                    {
                        DisplayGenericError();
                    }
                }
                else
                {
                    Page.Create(core, Owner, title, ref slug, parent, pageBody, status, core.Functions.GetLicenseId(), core.Functions.GetClassification());
                }
            }
            catch (PageTitleNotValidException)
            {
                SetError("You must give the page a title.");
                return;
            }
            catch (PageSlugNotValidException)
            {
                SetError("You must specify a page slug.");
                return;
            }
            catch (PageSlugNotUniqueException)
            {
                SetError("You must give your page a different name.");
                return;
            }
            catch (PageContentEmptyException)
            {
                SetError("You cannot save empty pages. You must post some content.");
                return;
            }
            catch (PageOwnParentException)
            {
                SetError("You cannot have a page as it's own parent.");
                return;
            }

            if (status == PageStatus.Draft)
            {
                SetRedirectUri(BuildUri("drafts"));
                core.Display.ShowMessage("Draft Saved", "Your draft has been saved.");
            }
            else
            {
                SetRedirectUri(BuildUri("manage"));
                core.Display.ShowMessage("Page Published", "Your page has been published");
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:79,代码来源:AccountPagesWrite.cs

示例5: UpdateInstall

        public bool UpdateInstall(Core core, Primitive viewer)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (!HasInstalled(core, viewer))
            {
                Install(core, viewer);
            }
            else
            {
                Application newApplication = Application.GetApplication(core, AppPrimitives.Member, this);

                Dictionary<string, PageSlugAttribute> slugs = newApplication.GetPageSlugs(viewer.AppPrimitive);

                foreach (string slug in slugs.Keys)
                {
                    if ((slugs[slug].Primitive & viewer.AppPrimitive) == viewer.AppPrimitive)
                    {
                        SelectQuery query = new SelectQuery("user_pages");
                        query.AddFields("page_id");
                        query.AddCondition("page_item_id", viewer.Id);
                        query.AddCondition("page_item_type_id", viewer.TypeId);
                        query.AddCondition("page_title", slugs[slug].PageTitle);
                        query.AddCondition("page_slug", slug);
                        query.AddCondition("page_parent_path", string.Empty);

                        if (core.Db.Query(query).Rows.Count == 0)
                        {
                            string tSlug = slug;
                            Page myPage = Page.Create(core, false, viewer, slugs[slug].PageTitle, ref tSlug, 0, string.Empty, PageStatus.PageList, 0, Classifications.None);

                            if (myPage != null)
                            {
                                if (viewer is User)
                                {
                                    myPage.Access.Viewer = (User)viewer;
                                }

                                if (myPage.ListOnly)
                                {
                                    if (HasIcon)
                                    {
                                        myPage.Icon = Icon;
                                        try
                                        {
                                            myPage.Update();
                                        }
                                        catch (UnauthorisedToUpdateItemException)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                Page myPage = new Page(core, viewer, slug, string.Empty);

                                if (viewer is User)
                                {
                                    myPage.Access.Viewer = (User)viewer;
                                }

                                if (myPage.ListOnly)
                                {
                                    myPage.Title = slugs[slug].PageTitle;
                                    if (!string.IsNullOrEmpty(Icon))
                                    {
                                        myPage.Icon = Icon;
                                    }

                                    myPage.Update();
                                }
                            }
                            catch (PageNotFoundException)
                            {
                                string tSlug = slug;
                                Page myPage = Page.Create(core, false, viewer, slugs[slug].PageTitle, ref tSlug, 0, string.Empty, PageStatus.PageList, 0, Classifications.None);

                                if (viewer is User)
                                {
                                    myPage.Access.Viewer = (User)viewer;
                                }

                                if (myPage.ListOnly)
                                {
                                    if (!string.IsNullOrEmpty(Icon))
                                    {
                                        myPage.Icon = Icon;
                                    }

                                    myPage.Update();
                                }
                            }
                        }
//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:ApplicationEntry.cs


注:本文中的Page.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。