Beispiel #1
0
 public void SaveAbout(AboutConfig conf)
 {
     var configSettings = new ConfigSettings();
     var config = new AboutConfig(configSettings, "About", Server.MapPath("~/Settings"))
     {
         FirstLine = conf.FirstLine,
         SecondLine = conf.SecondLine,
         PhotoPath = conf.PhotoPath,
         QrcodePath = conf.QrcodePath,
         ThirdLine = conf.ThirdLine,
         Profile = conf.Profile,
         Wechat = conf.Wechat,
         Email = conf.Email
     };
     config.Save();
 }
Beispiel #2
0
 public async Task<ViewResult> Item(string id)
 {
     if (id.Equals("about", StringComparison.CurrentCultureIgnoreCase))
     {
         var configSettings = new ConfigSettings();
         var config = new AboutConfig(configSettings, "About", Server.MapPath("~/Settings"));
         config.Load();
         return View("About", config);
     }
     if (id.Equals("guestbook", StringComparison.CurrentCultureIgnoreCase))
     {
         return View("Guestbook");
     }
     var cacheKey = "post_" + id;
     var post = RedisManager.GetItem<Post>(cacheKey);
     if (post == null)
     {
         post = await _postRepository.GetPostByAlias(id);
         if (post != null)
         {
             RedisManager.SetItem(cacheKey, post, new TimeSpan(0, Settings.Config.CacheExpired, 0));
         }
     }
     if (post != null)
     {
         var item = new PostItem
         {
             UniqueId = post.UniqueId,
             Title = post.Title,
             CategoryAlias = post.CategoryAlias,
             CateName = await _categoryRepository.GetNameByAlias(post.CategoryAlias),
             CreateTimeStr = post.CreateTime.ToString("yy-MM-dd HH:mm"),
             ViewCount = post.ViewCount,
             LabelList = JsonConvert.DeserializeObject<List<LabelShow>>(post.Labels).Select(t => t.Text).ToList(),
             Summary = post.Summary,
             Content = post.Content
         };
         return View(item);
     }
     else
     {
         var error = new Elmah.Error(new Exception("文章id:" + id + " 不存在!"), System.Web.HttpContext.Current) { StatusCode = 404 };
         Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(error);
         return View("Error404");
     }
 }
Beispiel #3
0
 /// <summary>
 /// 关于管理
 /// </summary>
 /// <returns></returns>
 public ActionResult AboutManage()
 {
     var configSettings = new ConfigSettings();
     var config = new AboutConfig(configSettings, "About", Server.MapPath("~/Settings"));
     config.Load();
     return View(config);
 }