public async Task <ActionResult> Settings(SettingsViewModel model) { if (!ModelState.IsValid) { return(View(model)); } // TODO: Setup/move validation to EF model? // TODO: Support ajax submit? // TODO: Wrap in a try/catch var repository = DataContext.Repositories.Where(model.RepoOwner, model.RepoName); if (repository != null) { repository.AccessToken = model.AccessToken; repository.RequireCla = model.RequireCla; repository.LicenseText = model.LicenseText; } else { repository = new Repository( owner: model.RepoOwner, name: model.RepoName, requireCla: model.RequireCla, accessToken: model.AccessToken, licenseText: model.LicenseText); DataContext.Repositories.Add(repository); } DataContext.SaveChanges(); await GitHubService.EnableWebHook(repository); TempData["settingsChanged"] = new SettingsChangedNotification(repository.RequireCla ? "success" : "warning", repository); return(Redirect(string.Format("/{0}/{1}/", model.RepoOwner, model.RepoName))); }
public override void HandlePushNotification(string func, List <byte[]> args) { //try { if (Application.Current == null) { return; // not ready yet } if (func == "ActivityNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ActivityNotification?.Invoke(this, new Priv10Engine.FwEventArgs() { guid = GetGuid(args[0]), entry = GetLogEntry(args[1]), progID = GetProgID(args[2]), services = GetStrList(args[3]), update = GetBool(args[4]) }); })); } else if (func == "RuleChangeNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { RuleChangeNotification?.Invoke(this, new Priv10Engine.ChangeArgs() { prog = GetProg(args[0]), rule = GetRule(args[1]), type = GetEnum <Priv10Engine.RuleEventType>(args[2]), action = GetEnum <Priv10Engine.RuleFixAction>(args[3]) }); })); } else if (func == "ProgUpdateNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ProgUpdateNotification?.Invoke(this, new Priv10Engine.UpdateArgs() { guid = GetGuid(args[0]), type = GetEnum <Priv10Engine.UpdateArgs.Types>(args[1]) }); })); } else if (func == "SettingsChangedNotification") { Application.Current.Dispatcher.BeginInvoke(new Action(() => { SettingsChangedNotification?.Invoke(this, new EventArgs()); })); } else { throw new Exception("Unknown Notificacion"); } } //catch (Exception err) //{ // AppLog.Exception(err); //} }