public ActionResult TimerSave(string timerId, string timerName, string timerMessage, string timerInterval, string timerActive) { int idInt = 0; if (!string.IsNullOrWhiteSpace(timerId)) { idInt = Convert.ToInt32(timerId); } try { bool activeTimerBool = !string.IsNullOrEmpty(timerActive) && timerActive.Equals("1"); var timer = new YTBot.Models.Timer() { Id = idInt, Active = activeTimerBool, TimerInterval = Convert.ToInt32(timerInterval), TimerName = timerName, TimerResponse = timerMessage }; var savedTimer = ContextService.SaveTimer(timer, User.Identity.Name); return(Json(new { data = "1", message = "Saved timer", timerId = savedTimer.Id }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(new { data = "-1", message = e.Message }, JsonRequestBehavior.AllowGet)); } }