Example #1
0
        public void VerifyCreatesSimplePageTreeCorrectly()
        {
            var page = new SimplePage();

            App.Content = page;

            var snapshotCreator = new ElementSnapshotCreator(testPropertyNames, page);

            var pageSnapshot = snapshotCreator.CreateSnapshot();

            Assert.AreEqual(testPropertyNames, pageSnapshot.PropertyNames);
            Assert.AreEqual("SimplePageName", pageSnapshot.ElementName);
            Assert.AreEqual("VisualTreeAnalyzers.Tests.TestInfra.DemoVisualTrees.SimplePage", pageSnapshot.FullTypeName);
            Assert.AreEqual(1, pageSnapshot.Children.Count);

            var gridSnapshot = pageSnapshot.Children[0];

            Assert.AreEqual(testPropertyNames, gridSnapshot.PropertyNames);
            Assert.AreEqual("RootGrid", gridSnapshot.ElementName);
            Assert.AreEqual("Windows.UI.Xaml.Controls.Grid", gridSnapshot.FullTypeName);
            Assert.AreEqual(1, gridSnapshot.Children.Count);
            Assert.AreEqual("#FFD3D3D3", (gridSnapshot.PropertyValues[3] as SolidColorBrush).Color.ToString());

            var textBlockSnapshot = gridSnapshot.Children[0];

            Assert.AreEqual(testPropertyNames, textBlockSnapshot.PropertyNames);
            Assert.AreEqual("ExampleTextBlock", textBlockSnapshot.ElementName);
            Assert.AreEqual("Windows.UI.Xaml.Controls.TextBlock", textBlockSnapshot.FullTypeName);
            Assert.AreEqual(0, textBlockSnapshot.Children.Count);
            Assert.AreEqual("#FF006400", (textBlockSnapshot.PropertyValues[4] as SolidColorBrush).Color.ToString());
            Assert.AreEqual("Some text", textBlockSnapshot.PropertyValues[5]);
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                SimplePage simplePage = new SimplePage();

                if (!string.IsNullOrEmpty(Input.CustomUrl) || !string.IsNullOrWhiteSpace(Input.CustomUrl))
                {
                    if (Input.CustomUrl.Contains(" "))
                    {
                        ModelState.AddModelError(string.Empty, "Custom Url can't contain spaces.");
                        return(Page());
                    }
                    simplePage.CustomUrl = Input.CustomUrl;
                }

                simplePage.Title = Input.Title;
                simplePage.HTML  = Input.HTML;

                (bool, string)result = await _simplePageService.AddNewPageAsync(simplePage);

                if (!result.Item1)
                {
                    ModelState.AddModelError(string.Empty, result.Item2);
                    return(Page());
                }
                else
                {
                    StatusMessage = result.Item2;
                    return(LocalRedirect("/Admin/SimplePages"));
                }
            }

            return(Page());
        }
Example #3
0
        public object ListTaskPage(int pageIndex, int pageSize)
        {
            SqlSugarClient  db          = base.Repository.GetDbContext();
            int             totalNumber = 0;
            IList <DmeTask> tasks       = db.Queryable <DmeTask>().OrderBy(t => t.CreateTime, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalNumber);

            if (0 == tasks?.Count)
            {
                return(0);
            }
            IList <TaskRespDTO> taskRespDTOs = new List <TaskRespDTO>();

            foreach (var item in tasks)
            {
                TaskRespDTO dto = new TaskRespDTO
                {
                    Task         = item,
                    Model        = db.Queryable <DmeModel>().Single(m => m.Id == item.ModelId),
                    ModelVersion = db.Queryable <DmeModelVersion>().Single(mv => mv.Id == item.VersionId)
                };
                taskRespDTOs.Add(dto);
            }
            SimplePage <TaskRespDTO> page = new SimplePage <TaskRespDTO>(pageIndex, pageSize, totalNumber, taskRespDTOs);

            return(page);
        }
Example #4
0
        public App()
        {
            InitializeComponent();

            //create ViewModel
            var viewModel = new SimpleViewModel();

            MainPage = new SimplePage(viewModel);
        }
Example #5
0
 public SimplePageVM Get(SimplePage page)
 {
     return(new SimplePageVM(page)
     {
         EntityWithTags = page.Children.OrderBy(x => x.WebSortOrder).Select(sp =>
                                                                            EntityWithList.New((IEntityCommonInfo)sp,
                                                                                               sp.Children.OrderBy(x => x.WebSortOrder).Cast <IEntityCommonInfo>())).ToList(),
     });
 }
Example #6
0
 public static TagBuilder SimplePageLink(this HtmlHelper helper, SimplePage page)
 {
     if (page.WithoutLink)
     {
         return(new TagBuilder("span")
         {
             InnerHtml = page.LinkTitle
         });
     }
     return(HtmlControls.Anchor(page.Url, page.LinkTitle));
 }
Example #7
0
        /// <summary>
        /// Deletes page by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Tupple of bool and string.</returns>
        public async Task <(bool, string)> DeletePageByIdAsync(int id)
        {
            SimplePage simplePage = await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.Id == id);

            if (simplePage != null)
            {
                _dbContext.SimplePages.Remove(simplePage);
                await _dbContext.SaveChangesAsync();

                return(true, "Page deleted successfully");
            }
            return(false, "Page with the Id: " + id + " not found.");
        }
Example #8
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id != null)
            {
                SimplePage = await _simplePageService.GetPageByIdAsync((int)id);

                if (SimplePage != null)
                {
                    DeleteId = (int)id;
                    return(Page());
                }
                return(LocalRedirect("/Admin/SimplePages"));
            }
            return(LocalRedirect("/Admin/SimplePages"));
        }
        public async Task <IActionResult> OnGetAsync(string url)
        {
            // First we check for custorm url.
            SimplePage = await _simplePageService.GetPageByCustomUrl(url);

            if (SimplePage == null)
            {
                SimplePage = await _simplePageService.GetPageByUrl(url);

                if (SimplePage != null)
                {
                    return(Page());
                }
                return(LocalRedirect("/errors/404"));
            }
            return(Page());
        }
Example #10
0
    void Start()
    {
        mPageList.Clear();
        for (int i = 0; i < PageList.Length; ++i)
        {
            GameObject go = GameObject.Instantiate(PageList[i]);
            go.name                 = PageList[i].name;
            go.transform.parent     = PageRoot.transform;
            go.transform.localScale = Vector3.one;
            //go.transform.localPosition = Vector3.zero;

            var rt = go.GetComponent <RectTransform>();
            rt.offsetMin = Vector2.zero;
            rt.offsetMax = Vector2.zero;

            SimplePage _sp = go.GetComponent <SimplePage>();
            go.SetActive(false);
            mPageList.Add(_sp.name, _sp);
        }
        Show("SmileMainPage");
    }
Example #11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id != null)
            {
                SimplePage simplePage = await _simplePageService.GetPageByIdAsync((int)id);

                if (simplePage == null)
                {
                    return(LocalRedirect("/Admin/SimplePages"));
                }

                Input           = new InputModel();
                Input.Id        = simplePage.Id;
                Input.Title     = simplePage.Title;
                Input.CustomUrl = simplePage.CustomUrl;
                Input.HTML      = simplePage.HTML;

                return(Page());
            }
            return(LocalRedirect("/Admin/SimplePages"));
        }
Example #12
0
        /// <summary>
        /// Updates page.
        /// </summary>
        /// <param name="simplePage"></param>
        /// <returns>Tupple of bool and string.</returns>
        public async Task <(bool, string)> UpdatePageAsync(SimplePage simplePage)
        {
            if (simplePage == null)
            {
                return(false, "Null object reference provided.");
            }
            SimplePage simplePageDb = await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.Id == simplePage.Id);

            if (simplePageDb != null)
            {
                if (!string.IsNullOrEmpty(simplePage.CustomUrl))
                {
                    if (!(await _dbContext.SimplePages.SingleOrDefaultAsync(x => (x.CustomUrl.Equals(simplePage.CustomUrl) && x.Id != simplePage.Id)) == null))
                    {
                        return(false, "Custom Url already exists.");
                    }
                }

                if (simplePage.Title.Equals("Home") && !simplePageDb.Title.Equals("Home"))
                {
                    SimplePage homePage = await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.Title.Equals(simplePage.Title));

                    if (homePage != null)
                    {
                        return(false, "There can only be one page with a title Home.");
                    }
                }


                simplePageDb.Title     = simplePage.Title;
                simplePageDb.CustomUrl = simplePage.CustomUrl;
                simplePageDb.HTML      = simplePage.HTML;

                _dbContext.SimplePages.Update(simplePageDb);
                await _dbContext.SaveChangesAsync();

                return(true, "Page updated successfully.");
            }
            return(false, "Page with the Id: " + simplePage.Id + " not found.");
        }
Example #13
0
        public List <string> GetBreadCrumbs(SimplePage model, bool includeIt,
                                            bool withoutRoot)
        {
            var breadcrumb = new List <string>();

            if (model == null)
            {
                return(breadcrumb);
            }
            if (model.SysName != null)
            {
                var path = GetBreadCrumbPart().GetPath(model.SysName);
                if (path != null)
                {
                    return(path.Select(bc => bc.Link).Reverse().ToList());
                }
            }
            var parent  = model.MainParent;
            var parents = new List <SimplePage>();

            while (parent != null)
            {
                parents.Add(parent);
                parent = parent.MainParent;
            }
            parents.Reverse();
            if (includeIt || withoutRoot)
            {
                parents = parents.Skip(1).ToList();
            }
            foreach (var page in parents.Where(p => !p.WithoutLink))
            {
                AddLink(breadcrumb, page);
            }
            if (includeIt && !model.WithoutLink)
            {
                AddLink(breadcrumb, model);
            }
            return(breadcrumb);
        }
Example #14
0
        /// <summary>
        /// Adds language variant content to the content item with the supplied codename
        /// </summary>
        /// <param name="codename">Codename of the content item needed</param>
        /// <returns></returns>
        public async Task <Guid> CreateItemVariantAsync(string codename)
        {
            const string htmlMarkup = @"<h1>Some content</h1>
                        <p>This is the content</p>";

            if (!IsValidHtml(htmlMarkup))
            {
                return(Guid.Empty);
            }

            var content = new SimplePage
            {
                PageTitle   = "Test import",
                PageContent = htmlMarkup,
                DishColour  = new[]
                {
                    TaxonomyTermIdentifier.ByCodename("green")
                },
                PageTeaser = new AssetIdentifier[0]
            };

            // Specifies the content item and the language variant
            ContentItemIdentifier        itemIdentifier     = ContentItemIdentifier.ByCodename(codename);
            LanguageIdentifier           languageIdentifier = LanguageIdentifier.DEFAULT_LANGUAGE;
            ContentItemVariantIdentifier identifier         = new ContentItemVariantIdentifier(itemIdentifier: itemIdentifier, languageIdentifier: languageIdentifier);

            // Upserts a language variant of your content item
            try
            {
                ContentItemVariantModel <SimplePage> response = await _managementClient.UpsertContentItemVariantAsync <SimplePage>(identifier, content);

                return(response.Item.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"ERROR: {ex.Message}");
                return(Guid.Empty);
            }
        }
Example #15
0
        /// <summary>
        /// Adds a new simple page.
        /// </summary>
        /// <param name="simplePage"></param>
        /// <returns>Tupple of bool and string.</returns>
        public async Task <(bool, string)> AddNewPageAsync(SimplePage simplePage)
        {
            if (!string.IsNullOrEmpty(simplePage.CustomUrl))
            {
                if (!(await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.CustomUrl.Equals(simplePage.CustomUrl)) == null))
                {
                    return(false, "Custom Url already exists.");
                }
            }

            SimplePage homePage = await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.Title.Equals(simplePage.Title));

            if (homePage != null)
            {
                return(false, "There can only be one page with a title Home.");
            }

            _dbContext.SimplePages.Add(simplePage);
            await _dbContext.SaveChangesAsync();

            return(true, "Page successfully added.");
        }
Example #16
0
        public async Task <SimplePage> GetPageByUrl(string url)
        {
            if (url != null)
            {
                string[] splitUrl = url.Split('-', 2);

                if (splitUrl.Length == 2)
                {
                    int id;

                    bool idParsedResult = int.TryParse(splitUrl[0], out id);

                    if (idParsedResult)
                    {
                        SimplePage simplePage = await _dbContext.SimplePages.SingleOrDefaultAsync(x => x.Id == id && string.Compare(splitUrl[1], x.Title) == 0);

                        return(simplePage);
                    }
                }
            }
            return(null);
        }
Example #17
0
        private ActionResult GetBestResult(string fullName, string imageName,
                                           string name,
                                           string postfix = null)
        {
            var simplePage = new SimplePage {
                Title = "Свидетельство " +
                        StringUtils.AngleBrackets(name)
            };
            var model =
                Tuple.New(simplePage,
                          fullName, imageName);
            var certificateFileSys = UserImages.GetGraduateCertificateFileSys(imageName, fullName);

            if (!System.IO.File.Exists(certificateFileSys))
            {
                using (var image = Image.FromFile(UserImages.GetGraduateCertificateFileSys(
                                                      imageName, "default" + postfix))) {
                    ImageUtils.DrawFullNameStringBest(imageName, image, fullName).Save(certificateFileSys);
                }
            }
            return(View(ViewNames.BestStudent, CommonVM.New(model, model.V1.Title)));
        }
Example #18
0
    public SimplePage Show(string pageName)
    {
        SimplePage result = null;

        foreach (var kv in mPageList)
        {
            var show = kv.Key == pageName;
            kv.Value.gameObject.SetActive(show);
            if (show)
            {
                result = kv.Value;
            }
            else
            {
                kv.Value.Leave();
            }
        }

        if (result)
        {
            result.Refresh();
        }
        return(result);
    }
Example #19
0
 public List <string> GetBreadCrumbs(SimplePage model)
 {
     return(GetBreadCrumbs(model, false, false));
 }
Example #20
0
 public List <string> GetBreadCrumbs(SimplePage model, bool includeIt)
 {
     return(GetBreadCrumbs(model, includeIt, false));
 }
Example #21
0
        public async Task <IActionResult> OnGetAsync()
        {
            SimplePage = await _simplePageService.GetPageByTitleAsync("Home");

            return(Page());
        }