public ActionResult Loyalty() { var botChannelSettings = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name)); if (botChannelSettings.Loyalty != null) { return(Json(JsonConvert.SerializeObject(botChannelSettings.Loyalty))); } else { var loyalty = new Loyalty(); return(Json(JsonConvert.SerializeObject(loyalty))); } }
public ActionResult Preferences(string message = null) { var userName = User.Identity.Name; var user = ContextService.GetUser(userName); var userBotSettings = ContextService.GetBotUserSettingsForUser(user); var model = new PrefViewModel() { username = userBotSettings.BotUsername, password = userBotSettings.BotPassword, channel = userBotSettings.BotChannel, channelToken = userBotSettings.ChannelToken }; ViewBag.Message = message; return(View(model)); }
public ActionResult Index() { // get users bot settings var userBotSettings = ContextService.GetBotUserSettingsForUser(ContextService.GetUser(User.Identity.Name)); var userLoyalty = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name)).Loyalty; var timers = ContextService.GetTimers(ContextService.GetUser(User.Identity.Name)); var triggers = ContextService.GetTriggers(ContextService.GetUser(User.Identity.Name)); var bannedWords = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name)) .BannedWords; if (bannedWords == null) { bannedWords = new List <BannedWord>(); } var stringBannedWords = new List <string>(); foreach (var bannedWord in bannedWords) { stringBannedWords.Add(bannedWord.Word); } var loyalty = userLoyalty ?? new Loyalty(); var dashboardViewModel = new DashboardViewModel() { BotUserSettings = userBotSettings, LoyaltySettings = loyalty, Timers = timers, Triggers = triggers, BannedWords = string.Join(",", stringBannedWords) }; // send user to bot preferences page if not set if (string.IsNullOrWhiteSpace(userBotSettings.BotChannel) || string.IsNullOrWhiteSpace(userBotSettings.BotUsername) || string.IsNullOrWhiteSpace(userBotSettings.BotUsername)) { RedirectToAction("Preferences", new { message = "Please set your bot account and channel information" }); } // assert that return(View(dashboardViewModel)); }
public ActionResult PreferencesSave(string botusername, string passwordinput, string channel, string channelToken) { try { var botUserSettings = new BotUserSettings() { User = ContextService.GetUser(User.Identity.Name), BotUsername = botusername ?? "", BotPassword = passwordinput ?? "", BotChannel = channel ?? "", ChannelToken = channelToken ?? "" }; ContextService.SetBotUserSettingsForUser(botUserSettings); return(Json(new { data = "1", message = "Saved!" }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { data = "-1", message = "Error saving: " + e.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult LoyaltySave(string loyaltyName, string loyaltyValue, string loyaltyInterval, string track) { try { var userName = User.Identity.Name; var user = ContextService.GetUser(userName); var loyalty = new Loyalty(); if (track == null) { loyalty.Track = false; } else { if (Convert.ToInt32(track) == 1) { loyalty.Track = true; } else { loyalty.Track = false; } } loyalty.LoyaltyName = loyaltyName; loyalty.LoyaltyInterval = Convert.ToInt32(loyaltyInterval); loyalty.LoyaltyValue = Convert.ToInt32(loyaltyValue); ContextService.SetLoyalty(user, loyalty); return(Json(new { data = "1", message = "Saved loyalty" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { data = "-1", message = "Error on save: " + exception.Message }, JsonRequestBehavior.AllowGet)); } }