public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(""); } var bdeId = (int)value; return(BDEService.GetBDEs().FirstOrDefault(x => x.idBDE == bdeId)?.Name); }
//Edit a client public EditClientViewModel(Client client) { WindowName = "Edition d'un client"; IsAddClientVisible = false; IsValidateChangesVisible = true; NewClient = new Client { Nom = client.Nom, IdCarte = client.IdCarte, CodeSecret = client.CodeSecret, IdBde = client.IdBde, Credit = client.Credit }; BDEs = new List <BDE>(BDEService.GetBDEs()); SelectedBde = BDEs.FirstOrDefault(x => x.Id == client.IdBde); Quit = new RelayCommand(() => Close(), o => true); GenerateNewPasskey = new RelayCommand(() => { Passkey = ClientService.GenerateNewPasskey(); }, o => true); ValidateChanges = new RelayCommand(() => { if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(BadgeID) || string.IsNullOrWhiteSpace(BadgeID) || BadgeID.Length > 15 || SelectedBde == null || double.IsNaN(Balance) || Balance < 0.00) { FormNotValid(); return; } NewClient.IdBde = SelectedBde.Id; ClientService.ValidateChanges(client, NewClient); var dialogService = new DialogService(); dialogService.ShowInformationModern("Le compte client a correctement été mis à jour !", "Modifications effectuées"); Close(); }, o => true); }
//Edit a client public EditClientViewModel(Client client) { WindowName = "Edition d'un client"; IsAddClientVisible = false; IsValidateChangesVisible = true; NewClient = new Client { Name = client.Name, BadgeID = client.BadgeID, Passkey = client.Passkey, IdBDE = client.IdBDE, Balance = client.Balance }; BDEs = new List <BDE>(BDEService.GetBDEs()); SelectedBde = BDEs.FirstOrDefault(x => x.idBDE == client.IdBDE); Quit = new RelayCommand(() => Close(), o => true); GenerateNewPasskey = new RelayCommand(() => { Passkey = ClientService.GenerateNewPasskey(); }, o => true); ValidateChanges = new RelayCommand(() => { if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(BadgeID) || string.IsNullOrWhiteSpace(BadgeID) || BadgeID.Length > 15 || SelectedBde == null || double.IsNaN(Balance) || Balance < 0.00) { FormNotValid(); return; } NewClient.IdBDE = SelectedBde.idBDE; ClientService.ValidateChanges(client, NewClient); var dialogService = new DialogService(); dialogService.ShowInformationWindow("Le compte client a correctement été mis à jour !", "Modifications effectuées", MessageBoxButton.OK, MessageBoxImage.Information); Close(); }, o => true); }
//Add a new client public EditClientViewModel() { WindowName = "Ajout d'un client"; IsAddClientVisible = true; IsValidateChangesVisible = false; NewClient = new Client(); Passkey = ClientService.GenerateNewPasskey(); BDEs = new List <BDE>(BDEService.GetBDEs()); SelectedBde = BDEs.FirstOrDefault(); Quit = new RelayCommand(() => Close(), o => true); GenerateNewPasskey = new RelayCommand(() => { Passkey = ClientService.GenerateNewPasskey(); }, o => true); AddClient = new RelayCommand(() => { if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(BadgeID) || string.IsNullOrWhiteSpace(BadgeID) || BadgeID.Length > 15 || SelectedBde == null || double.IsNaN(Balance) || Balance < 0.00) { FormNotValid(); return; } NewClient.IdBDE = SelectedBde.idBDE; ClientService.AddClient(NewClient); var dialogService = new DialogService(); dialogService.ShowInformationWindow("Le compte client a correctement été ajouté !", "Ajout effectué", MessageBoxButton.OK, MessageBoxImage.Information); Close(); }, o => true); }
private void UpdateDues() { _bdeDues = BDEService.GetBDEDues(_dateFrom, _dateTo); OnPropertyChanged(nameof(BDEDues)); }