示例#1
0
		public ActionResult ChangeTheme(string theme)
		{
			if (String.IsNullOrEmpty(theme)) {
				return JsonError("Тема не указана", JsonRequestBehavior.AllowGet);
			}
			
			IThemeable themable = HttpContext.ApplicationInstance as IThemeable;
			
			if (themable == null) {
				return JsonError("Приложение не поддерживает темы.", JsonRequestBehavior.AllowGet);
			}

			if (!themable.SetTheme(theme)) {
				return JsonError("Тема не найдена", JsonRequestBehavior.AllowGet);
			}

			UserContext.Theme = theme;

			IAppConfiguration config = HttpContext.ApplicationInstance as IAppConfiguration;

			return JsonModel(
				new { 
					theme = theme, 
					css = Url.Content(config.GetWebAssetThemeCssStylePath(theme))
				}
				, JsonRequestBehavior.AllowGet);
		}