public JsonResult Edit(string id, [Bind("DeveloperId,GithubUsername,PrivacyForGithub,CodeforcesUsername,PrivacyForCodeforces,UhuntUsername,PrivacyForUhunt")] WorkingProfile workingProfile) { if (id != workingProfile.DeveloperId) { return(null); } if (ModelState.IsValid) { try { _context.Update(workingProfile); _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkingProfileExists(workingProfile.DeveloperId)) { return(null); } else { throw; } } return(Json(workingProfile)); } return(null); }
private void SavePrompt(FormClosingEventArgs e) { var result = MessageBox.Show( "Save changes?", "Edit Profile", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question ); switch (result) { case DialogResult.Yes: if (!SaveProfile()) { e.Cancel = true; } break; case DialogResult.No: WorkingProfile.DiscardChanges(); break; case DialogResult.Cancel: e.Cancel = true; break; } }
public async Task<IActionResult> Register(InitDevelopers initDevelopers, string returnUrl) { if (ModelState.IsValid) { var mailAddress = new MailAddress(initDevelopers.DevEmail); initDevelopers.DevId = Guid.NewGuid().ToString().Replace("-", ""); var userObject = new IdentityUser { Id = initDevelopers.DevId, UserName = mailAddress.User, Email = initDevelopers.DevEmail, LockoutEnabled = false }; var userCreationResult = await _userManager.CreateAsync(userObject, initDevelopers.DevPassword); if (userCreationResult.Succeeded) { await _signInManager.SignInAsync(userObject, true); var shortBio = new ShortBio { DeveloperId = initDevelopers.DevId, DeveloperName = mailAddress.User }; var social = new SocialProfile { DeveloperId = initDevelopers.DevId }; var workingProfile = new WorkingProfile { DeveloperId = initDevelopers.DevId }; _context.Add(shortBio); _context.Add(social); _context.Add(workingProfile); await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } return RedirectToAction("Edit", "ShortBios", new { id = initDevelopers.DevId }); } foreach (var error in userCreationResult.Errors) { ModelState.AddModelError("", error.Description); } } return View(initDevelopers); }
private Task CopySettingsFromCurrentProfileTo(WorkingProfile newProfile) { return(Task.Run(() => { var settingsService = Settings; foreach (var workspace in TfsContext.GetWorkspaces()) { settingsService.CopySettings(SelectedProfile, workspace, newProfile, workspace); } })); }
public async void AddNewProfile(string name, bool copySettingsFromCurrent) { var newProfile = WorkingProfile.CreateProfile(name); Profiles.Add(newProfile); WorkingProfile.SaveProfiles(Profiles); await CopySettingsFromCurrentProfileTo(newProfile); SelectedProfile = newProfile; RaisePropertyChanged(() => HasProfiles); }
private bool SaveProfile() { if (WorkingProfile.ValidateData()) { WorkingProfile.SaveChanges(); return(true); } MessageBox.Show( "Some field you've inputted is invalid!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return(false); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public TfsContext(IServiceProvider serviceProvider) { AsyncOp = AsyncOperationManager.CreateOperation(null); //WorkItemsListViewHelper.Instance //TeamExplorerUtils.Instance ServiceProvider = serviceProvider; selectedProfile = WorkingProfile.DefaultProfile; TfsContextManager = serviceProvider.Get <ITeamFoundationContextManager2>(); TfsContextManager.ContextChanged += ConnectionContextChanged; IdentityManager = new TfsIdentityManager(this); BuildDetailManager = new BuildDetailManager(this); WorkItemManager = new WorkItemManager(this); SelectedDirectory = GetService <SettingsService>().Get <string>(SettingsKeys.LastDirectoryKey); }
public IEnumerable <string> GetPropertiesForWorkspace(WorkingProfile profile, Workspace workspace) { string sourceWorkspaceName = workspace != null ? workspace.Name : defaultWorkSpaceName; int xtra = new Regex(Regex.Escape(keySeperator)).Matches(sourceWorkspaceName).Count; Func <string, bool> profileFilterFunc = s => profile == null || profile.IsDefault || s.StartsWith(profile.Id.ToString()); Func <string, bool> workspaceFilterFunc = s => { if (s.Contains(keySeperator)) { var splits = s.Split(new[] { keySeperator }, StringSplitOptions.None); return(splits.Length > (3 + xtra) && (splits[2 + xtra] == sourceWorkspaceName || splits[2 + xtra] == defaultWorkSpaceName)); } return(false); }; return(settingsStore.GetPropertyNames(collectionPath).Where(profileFilterFunc).Where(workspaceFilterFunc)); }
private void AddNewProfile(WorkingProfile workingProfile) { IsEnabled = false; var nameEdit = new NameEdit((ne, value) => { AddNewProfile(value, ne.IsChecked); IsEnabled = true; }, ne => IsEnabled = true) { Watermark = "Enter a profile name <Required>", CheckboxText = "Copy Settings from current Profile", HasCheckbox = true, AcceptText = "Add" }; GetService <MainViewModel>().ExtraContent = nameEdit; }
public bool CopySettings(WorkingProfile sourceProfile, Workspace sourceWorkspace, WorkingProfile targetProfile, Workspace targetWorkspace) { bool changed = false; string sourceWorkspaceName = sourceWorkspace != null ? sourceWorkspace.Name : defaultWorkSpaceName; string targetWorkspaceName = targetWorkspace != null ? targetWorkspace.Name : defaultWorkSpaceName; int xtraTarget = new Regex(Regex.Escape(keySeperator)).Matches(targetWorkspaceName).Count; var propertyNamesToCopy = GetPropertiesForWorkspace(sourceProfile, sourceWorkspace); foreach (var propertyName in propertyNamesToCopy) { string newPropertyName = propertyName.Replace(sourceProfile.Id.ToString(), targetProfile.IsDefault ? string.Empty:targetProfile.Id.ToString()); if (!targetProfile.IsDefault && !newPropertyName.StartsWith(targetProfile.Id.ToString())) { newPropertyName = targetProfile.Id + newPropertyName; } if (newPropertyName.Contains(keySeperator)) { var splits = newPropertyName.Split(new[] { keySeperator }, StringSplitOptions.None); if (splits.Length > (3 + xtraTarget) && (splits[2 + xtraTarget] == sourceWorkspaceName || splits[2 + xtraTarget] == defaultWorkSpaceName)) { splits[2 + xtraTarget] = targetWorkspaceName; newPropertyName = splits.Aggregate("", (current, s) => current + keySeperator + s).Substring(1); } } if (propertyName.Contains("Delphi")) { } if (newPropertyName != propertyName) { Set(newPropertyName, Get(propertyName)); changed = true; } } return(changed); }
public void DeleteProfile(WorkingProfile profile) { if (profile != null && !profile.IsDefault) { var toDelete = profile; IsEnabled = false; var nameEdit = new NameEdit((ne, value) => { Profiles.Remove(toDelete); WorkingProfile.SaveProfiles(Profiles); SelectedProfile = Profiles.FirstOrDefault(); IsEnabled = true; RaisePropertyChanged(() => HasProfiles); }, ne => IsEnabled = true) { IsReadOnly = true, Value = $"Profile '{SelectedProfile.Name}' will be deleted!", AcceptText = "Delete" }; GetService <MainViewModel>().ExtraContent = nameEdit; } }
private void RestoreDefaultButton_Click(object sender, EventArgs e) { WorkingProfile.RestoreDefault(); BindProfileData(); }
public Task <bool> CopySettingsAsync(WorkingProfile sourceProfile, Workspace sourceWorkspace, WorkingProfile targetProfile, Workspace targetWorkspace) { return(Task.Run(() => CopySettings(sourceProfile, sourceWorkspace, targetProfile, targetWorkspace))); }
public bool HasSettings(WorkingProfile profile, Workspace workspace) { return(GetPropertiesForWorkspace(profile, workspace).Any()); }
private bool CanExecuteDeleteSelectedProfile(WorkingProfile arg) { return(arg != null && !arg.IsDefault); }
private void LoadProfiles() { Profiles.Clear(); Profiles.AddRange(WorkingProfile.LoadProfiles()); RaisePropertyChanged(() => HasProfiles); }