Example #1
0
 public IActionResult Edit(Widget record)
 {
     _widgetRepository.Update(record);
     return(Json(new WebResponseModel()
     {
         methodName = nameof(Edit)
     }));
 }
 public IActionResult Edit(UrlRecord record)
 {
     _urlRecordRepository.Update(record);
     return(Ok(new WebResponseModel
     {
         methodName = nameof(Edit)
     }));
 }
 public IActionResult Edit(Settings record)
 {
     _settingsRepository.Update(record);
     //return Ok(new WebResponseModel
     //{
     //    methodName = nameof(Edit)
     //});
     return(RedirectToAction(nameof(Index)));
 }
        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()));
        }
Example #5
0
 public IActionResult Edit(Resource record)
 {
     _resourceRepository.Update(record);
     return(RedirectToAction(nameof(Edit), new { id = record.Id }));
 }
Example #6
0
 public IActionResult Edit(Template template)
 {
     _templateRepository.Update(template);
     return(Ok(new WebResponseModel()));
 }