示例#1
0
        public async Task <IActionResult> Create([FromBody] Page page)
        {
            page.Id = DataUtil.GenerateUniqueId();
            var chosenSite = await _siteRepository.GetOneAsync(page.SiteId);

            var chosenTheme = await _themeRepository.GetOneAsync(chosenSite.ThemeId);

            var chosenPageTemplate = await _pageTemplateRepository.GetOneAsync(page.PageTemplateId);

            //var newVersion = new PageVersion
            //{
            //    Id = DataUtil.GenerateUniqueId(),
            //    CreatedDate = DateTime.UtcNow,
            //    Creator = _httpContextAccessor.HttpContext.User.Identity.Name,
            //    Name = "1",
            //    PageId = page.Id,
            //    Manifests = await _pageService.InitManifests(chosenPageTemplate, chosenTheme)
            //};

            //page.ChosenPageVersionId = newVersion.Id;
            await _pageRepository.AddAsync(page);

            //await _pageVersionRepository.AddAsync(newVersion);
            return(Ok());
        }
示例#2
0
        public async Task <IActionResult> Create([FromBody] Page page)
        {
            if (ModelState.IsValid)
            {
                page.Id = DataUtil.GenerateUniqueId();
                await _pageRepository.AddAsync(page);

                _logger.Info("Created page: {@page}", page);
                return(Ok(page.Id));
            }
            return(BadRequest());
        }