/// <summary> /// 获取网站活动配置 /// </summary> public string GetActityConfig() { var configList = ActivityCache.QueryActivityConfig(); var query = from c in configList select string.Format("{0}_{1}_{2}", c.ConfigKey, c.ConfigName, c.ConfigValue); return(string.Join("|", query.ToArray())); }
/// <summary> /// 更新网站活动配置 /// </summary> public CommonActionResult UpdateActivityConfig(string key, string value) { try { ActivityCache.UpdateActivityConfig(key, value); return(new CommonActionResult(true, "更新成功")); } catch (Exception ex) { return(new CommonActionResult(false, ex.Message)); } }
public IActionResult Delete(long id) { try { _dbcontext.ActivityRecords.Remove(_dbcontext.ActivityRecords.Single(r => r.Id == id)); _dbcontext.SaveChanges(); ActivityCache.InvalidateCache(); _logger.Log(LogSeverityLevel.Info, $"Deleted activity with ID: {id}"); } catch (Exception ex) { _logger.Log(LogSeverityLevel.Error, $"Error deleting activity with ID: {id}"); _logger.Log(LogSeverityLevel.Error, ex.Message); return(RedirectToAction("Log", "Home")); } return(RedirectToAction("Index", "Home")); }
public IActionResult SaveDescription(string description, long id) { try { var record = _dbcontext.ActivityRecords.Single(r => r.Id == id); record.Description = description; _dbcontext.SaveChanges(); ActivityCache.InvalidateCache(); _logger.Log(LogSeverityLevel.Info, $"Changed description for activity with ID: {id}"); } catch (Exception ex) { _logger.Log(LogSeverityLevel.Error, $"Error changing description for activity with ID: {id}"); _logger.Log(LogSeverityLevel.Error, ex.Message); return(RedirectToAction("Log", "Home")); } return(RedirectToAction("Run", "Home", new { id })); }
public IActionResult ToggleRace(long id) { try { var record = _dbcontext.ActivityRecords.Single(r => r.Id == id); record.IsRace = !record.IsRace; _dbcontext.SaveChanges(); ActivityCache.InvalidateCache(); _logger.Log(LogSeverityLevel.Info, $"Toggled IsRace for activity with ID: {id}"); } catch (Exception ex) { _logger.Log(LogSeverityLevel.Error, $"Error toggling IsRace for activity with ID: {id}"); _logger.Log(LogSeverityLevel.Error, ex.Message); return(RedirectToAction("Log", "Home")); } return(RedirectToAction("Run", "Home", new { id = id })); }
private ActionResult ChartMenuHelper(int index) { var numOfCharts = Enum.GetNames(typeof(ChartsMenuModel.ChartType)).Length; if (index == 0) { index = numOfCharts; } if (index == numOfCharts + 1) { index = 1; } return(index switch { 1 => View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext))), 2 => View("ChartsMetrics", new ChartsMetricsModel(ActivityCache.Get(_dbcontext))), 3 => View("ChartsWorkload", new ChartsWorkloadModel(ActivityCache.Get(_dbcontext))), 4 => View("ChartsVolume", new ChartsVolumeModel(ActivityCache.Get(_dbcontext))), 5 => View("ChartsComparison", new ChartsComparisonModel(ActivityCache.Get(_dbcontext))), 6 => View("ChartsEddington", new ChartsEddingtonModel(ActivityCache.Get(_dbcontext))), _ => View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext))) });
public IActionResult EditDescription(long id) { return(View("EditRun", ActivityCache.Get(_dbcontext).Single(a => a.Id == id))); }
public IActionResult Map() { return(View("Map", new MapModel(ActivityCache.Get(_dbcontext)))); }
public IActionResult Races() { return(View("Races", new RacesModel(ActivityCache.Get(_dbcontext).Where(a => a.IsRace).ToList()))); }
public IActionResult Stats() { return(View("Stats", new StatsModel(ActivityCache.Get(_dbcontext)))); }
public IActionResult Charts() { return(View("ChartsProgression", new ChartsProgressionModel(ActivityCache.Get(_dbcontext)))); }
public IActionResult Index() { return(View("Index", new IndexModel(ActivityCache.Get(_dbcontext)))); }
/// <summary> /// 根据activityId获取当前活动配置 /// </summary> /// <param name="activityId"></param> /// <returns></returns> public Task <OperationResult <FixedPriceActivityRoundResponse> > GetFixedPriceActivityRoundAsync(Guid activityId) => OperationResult.FromResultAsync(ActivityCache.GetFixedPriceActivityRoundCache(activityId));
/// <summary> /// 重置活动计数器 /// </summary> /// <param name="activityId"></param> /// <returns></returns> public Task <OperationResult <bool> > UpdateBaoYangPurchaseCountAsync(Guid activityId) => OperationResult.FromResultAsync(ActivityCache.UpdateBaoYangPurchaseCount(activityId));
/// <summary> /// 更新保养活动配置 /// </summary> /// <param name="activityId"></param> /// <returns></returns> public Task <OperationResult <bool> > UpdateBaoYangActivityConfigAsync(Guid activityId) => OperationResult.FromResultAsync(ActivityCache.UpdateBaoYangActivityConfig(activityId));
/// <summary> /// 根据key获取配置的值 /// </summary> /// <param name="key"></param> /// <returns></returns> public string QueryActivityConfig(string key) { return(ActivityCache.QueryActivityConfig(key).ConfigValue); }