public IActionResult Create(Page pageRecord, [FromServices] MongoDbBaseRepository <UrlRecord> urlRecordRepository)
        {
            //需要判断一下url
            if (!string.IsNullOrEmpty(pageRecord.Url))
            {
                pageRecord.Url = pageRecord.Url.ToLower();
            }


            var filters = Builders <UrlRecord> .Filter.Where(x => x.Type == UrlRecordType.Page && x.Slug == pageRecord.Url);

            var urlRecord = urlRecordRepository.SigleOrDefault(filters).Result;

            if (urlRecord != null)
            {
                throw new Exception($"URL:{pageRecord.Url} already exists");
            }
            //新的UrlRecord不存在,插入新的UrlRecord
            urlRecordRepository.Insert(new UrlRecord()
            {
                Slug     = pageRecord.Url,
                Type     = UrlRecordType.Page,
                RefValue = pageRecord.Id.ToString()
            });
            _pageRepository.Insert(pageRecord);

            return(Ok(new WebResponseModel()));
        }
        public IActionResult Edit(Page page, [FromServices] MongoDbBaseRepository <UrlRecord> urlRecordRepository)
        {
            if (page.Url != null)
            {
                page.Url = page.Url.ToLower();
            }

            var oldPage = _pageRepository.GetByIdAsync(page.Id).Result;
            var filters = Builders <UrlRecord> .Filter.Where(x => x.Type == UrlRecordType.Page && x.RefValue == oldPage.Id.ToString());

            var existsUrlRecord = urlRecordRepository.SigleOrDefault(filters).Result;

            if (existsUrlRecord == null)
            {
                //之前不存在,补充进去
                //for fix some page not set urlrecords issue
                var newUrlRecord = new UrlRecord()
                {
                    Slug     = page.Url,
                    Type     = UrlRecordType.Page,
                    RefValue = page.Id.ToString()
                };
                urlRecordRepository.Insert(newUrlRecord);
            }
            else if (page.Url != existsUrlRecord.Slug)
            {
                //旧页面的Url已存在,但是URL不相同,意味着在新页面编辑的时候更新了URL

                //旧的URL做301处理
                //keep old url, set old url redirect path
                existsUrlRecord.Type     = UrlRecordType.RedirectPermanent;
                existsUrlRecord.RefValue = page.Url;
                urlRecordRepository.Update(existsUrlRecord);

                //并创建新的页面
                //create new url for the new page
                var newUrlRecord = new UrlRecord()
                {
                    Slug     = page.Url,
                    Type     = UrlRecordType.Page,
                    RefValue = page.Id.ToString()
                };
                urlRecordRepository.Insert(newUrlRecord);
            }
            else
            {
                //other no change for url record
            }

            page.ModificationTime = DateTime.UtcNow;
            page.Title            = oldPage.Title;
            _pageRepository.Update(page);
            return(Ok(new WebResponseModel()));
        }