예제 #1
0
        protected void RankUp(object sender, EventArgs e)
        {
            int rank = int.Parse(((System.Web.UI.WebControls.LinkButton)sender).CommandArgument);
            List <TutorialPage> pages = new List <TutorialPage>();
            // Send everything to Service
            int i = 0;

            foreach (var item in LVTuto.Items)
            {
                i += 1;
                pages.Add(new TutorialPage()
                {
                    Text       = ((System.Web.UI.WebControls.TextBox)item.Controls[5]).Text,
                    Video      = checkVideo(((System.Web.UI.WebControls.TextBox)item.Controls[3]).Text),
                    PageNumber = int.Parse(((System.Web.UI.WebControls.TextBox)item.Controls[1]).Text),
                });
            }
            if (rank < pages.Count)
            {
                pages.FindAll(x => x.PageNumber == rank).ForEach(x => x.PageNumber     = -1);
                pages.FindAll(x => x.PageNumber == rank + 1).ForEach(x => x.PageNumber = rank);
                pages.FindAll(x => x.PageNumber == -1).ForEach(x => x.PageNumber       = rank + 1);

                using (Service1Client client = new Service1Client())
                {
                    UpdateTutorialItemResponse response = client.UpdateTutorialItem(
                        new UpdateTutorialItemRequest()
                    {
                        TutorialItem = new TutorialItem()
                        {
                            // the new Tutorial item object (with same _id)
                            _id          = TutorialID.Text,
                            Title        = TutorialTitle.Text,
                            Author       = Author.Text,
                            DateModified = DateTime.Now,
                            Pages        = pages.ToArray()
                        }
                    });

                    if (!response.Errored)
                    {
                        // the Tutorial item is now updated
                        Response.Redirect("~/TutorialEditor?id=" + Request.QueryString["id"]);
                    }
                }
            }
        }
예제 #2
0
        protected void NewPage(object sender, EventArgs e)
        {
            List <TutorialPage> pages = new List <TutorialPage>();
            // Send everything to Service
            int i = 0;

            foreach (var item in LVTuto.Items)
            {
                i += 1;
                pages.Add(new TutorialPage()
                {
                    Text       = ((System.Web.UI.WebControls.TextBox)item.Controls[5]).Text,
                    Video      = checkVideo(((System.Web.UI.WebControls.TextBox)item.Controls[3]).Text),
                    PageNumber = int.Parse(((System.Web.UI.WebControls.TextBox)item.Controls[1]).Text),
                });
            }

            pages.Add(new TutorialPage()
            {
                Text       = "Type your text here",
                Video      = "",
                PageNumber = pages.Count + 1
            });
            using (Service1Client client = new Service1Client())
            {
                UpdateTutorialItemResponse response = client.UpdateTutorialItem(
                    new UpdateTutorialItemRequest()
                {
                    TutorialItem = new TutorialItem()
                    {
                        // the new Tutorial item object (with same _id)
                        _id          = TutorialID.Text,
                        Title        = TutorialTitle.Text,
                        Author       = Author.Text,
                        DateModified = DateTime.Now,
                        Pages        = pages.ToArray()
                    }
                });

                if (!response.Errored)
                {
                    // the Tutorial item is now updated
                    Response.Redirect("~/TutorialEditor?id=" + Request.QueryString["id"]);
                }
            }
        }