/// <summary> /// Handles the Click event of the btnSaveOrgDetails control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param> private void btnSaveOrgDetails_Click(object sender, RoutedEventArgs e) { if (ApplicationViewModel.Instance.DemoMode) { DemoMode dm = new DemoMode(); dm.Show(); return; } if (addEditMode == Organizations.AddEditMode.Edit) { if (ValidateForm()) { organizationViewModel = new OrganizationViewModel(); organizationViewModel.DtoUpdated += new EventHandler <NotificationEventArgs <Exception> >(organizationViewModel_DtoUpdated); // OrganizationDto modelODto = organizationViewModel.OrganizationDtoList.Single(x => x.Id == this.selectedOrgID); modelODto = this.DataContext as OrganizationDto; modelODto.Name = tbOrganizationName.Text; modelODto.Active = (((ComboBoxItem)cboActive.SelectedItem).Content.ToString() == "Yes") ? true : false; organizationViewModel.Update(modelODto); //Code to show success message on edit organization //SucessMsg.Text = "Organization " + tbOrganizationName.Text + " has been updated."; //imgSMsg.Visibility = System.Windows.Visibility.Visible; //spMsg.Visibility = System.Windows.Visibility.Visible; } } else { if (ValidateForm()) { //string s = ((ComboBoxItem)cboActive.SelectedItem).Content.ToString(); bool IsActive = false; if (((ComboBoxItem)cboActive.SelectedItem).Content.ToString() == "Yes") { IsActive = true; } userOrgDto = new UserOrganizationDto(); newOrganizationDto = new OrganizationDto() { Active = true, Id = -1, Name = tbOrganizationName.Text, AdminCount = 0, AnalystCount = 0, DatasourceCount = 0, DatasourcesCount = 0, Description = null, SuperAdminCount = 0, TotalUserCount = 0 }; if (userDto != null) { newAdminDto = userDto; } else { newAdminDto = new UserDTO() { FirstName = tbFirstName.Text, LastName = tbLastName.Text, //OrganizationID = -1, Phone = tbPhone.Text, UserID = -1, //UserName = autoEmail.Text, //"default user name", //Email = autoEmail.Text, //RoleValue = 2, IsActive = true, IsExistingUser = false }; } //newOrganizationDto.AdminList = new List<UserDTO>(); //newOrganizationDto.AdminList.Add(newAdminDto); if (ApplicationViewModel.Instance.AuthenticationMode.ToString().ToLower() == "windows") { newAdminDto.Email = tbEmailAddress.Text.ToString().ToLower(); newAdminDto.UserName = tbUserId.Text.ToString().ToLower(); } else { newAdminDto.Email = autoEmail.Text.ToString().ToLower(); newAdminDto.UserName = autoEmail.Text; } userOrgDto.Organization = newOrganizationDto; userOrgDto.User = newAdminDto; userOrgDto.RoleId = 2; userOrgDto.Active = IsActive; organizationViewModel = new OrganizationViewModel(); organizationViewModel.DtoAdded += new EventHandler <NotificationEventArgs <Exception> >(organizationViewModel_DtoAdded); organizationViewModel.Add(userOrgDto); //Code to show success message on add organization //SucessMsg.Text = "Organization " + tbOrganizationName.Text + " has been added."; //imgSMsg.Visibility = System.Windows.Visibility.Visible; //spMsg.Visibility = System.Windows.Visibility.Visible; //spMsg.Background = new SolidColorBrush(Color.FromArgb(255, 241, 202, 194)); //pink BK to use in case of error //errMsg.Foreground = new SolidColorBrush(Color.FromArgb(255, 96, 25, 25)); //dark pink text color to use in case of error. //imgerrMsg.Visibility = System.Windows.Visibility.Collapsed; // error icon } } }