private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var currentButton = (Button)sender; if (currentButton == null) { return; } var dataContext = currentButton.DataContext as CompanyMapperDto; if (dataContext == null) { return; } var currentCompany = CompanyMappers.FirstOrDefault(x => x.Id == dataContext.Id); if (currentCompany == null) { return; } CompanyMappers.Remove(currentCompany); }
private void SaveCompanyInGrid_OnClick(object sender, RoutedEventArgs e) { Error.Content = string.Empty; if (_dataParametersNotExisting.Any(x => x.Value != ParameterStatus.Exist)) { List <IsoluctionParameterDto> dataParametersRetrieved; using ( var streamReader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\IsolucionParameter.json") ) { var jsonLicenseParameters = streamReader.ReadToEnd(); dataParametersRetrieved = JsonConvert.DeserializeObject <List <IsoluctionParameterDto> >(jsonLicenseParameters); } foreach (var parameterStatus in _dataParametersNotExisting) { switch (parameterStatus.Key) { case ParameterIsolucion.RutaAnexo: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.RutaWebSite: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.RutaArticulo: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.RutaLibreria: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.RutaHttpServicios: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.RutaBaseCacheDatos: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.AppRutaServicioWebSf: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.WebSite: ManageParameter(parameterStatus, dataParametersRetrieved); break; case ParameterIsolucion.GenericHandler: ManageParameter(parameterStatus, dataParametersRetrieved); break; default: throw new ArgumentOutOfRangeException(); } } var dialogResult = MessageBox.Show("Se guardara la configuración de la empresa ¿desea continuar?", "Isolucion", MessageBoxButton.YesNo); switch (dialogResult) { case MessageBoxResult.None: break; case MessageBoxResult.OK: CompanyMappers.Add(TheCompanyMapperDto); PathData.Visibility = Visibility.Collapsed; LicenseView.Visibility = Visibility.Collapsed; break; case MessageBoxResult.Cancel: Error.Content = "Seleccione las rutas de los parámetros faltantes o revisa la configuración del Isolucion instalado"; break; case MessageBoxResult.Yes: var companyMapped = CompanyMappers.FirstOrDefault(x => x.Name == TheCompanyMapperDto.Name); if (companyMapped != null) { CompanyMappers.Remove(companyMapped); } CompanyMappers.Add(TheCompanyMapperDto); PathData.Visibility = Visibility.Collapsed; LicenseView.Visibility = Visibility.Collapsed; break; case MessageBoxResult.No: Error.Content = "Seleccione las rutas de los parámetros faltantes o revisa la configuración del Isolucion instalado"; break; default: throw new ArgumentOutOfRangeException(); } return; } CompanyMappers.Add(TheCompanyMapperDto); PathData.Visibility = Visibility.Collapsed; }