private void DeleteClient(ClientSummary client) { if (client == null) { return; } PopupService.DisplayQuestion("Suppression de client", $"Etes-vous certain de vouloir supprimer le client {client.LastName} {client.FirstName}", QuestionActionButton.Yes(() => DeleteClientConfirmed(client)), QuestionActionButton.No()); }
private async Task LoadClientAsync(Guid id) { try { IsBusy = true; Client = await AsyncFake.CallAsync(ClientBL, x => x.GetClient(id)); // Initialize IsPurchaseDeletable if (Client.Purchases != null) { DateTime?lastVoucherIssueDate = Client.LastVoucherIssueDate; if (lastVoucherIssueDate.HasValue) { foreach (Purchase purchase in Client.Purchases) { purchase.IsPurchaseDeletable = purchase.Date > lastVoucherIssueDate.Value; } } else { foreach (Purchase purchase in Client.Purchases) { purchase.IsPurchaseDeletable = true; } } } // Initialize input fields _automaticCitySearch = false; // desactivate while filling client fields LastName = Client.LastName; FirstName = Client.FirstName; BirthDate = Client.BirthDate; Email = Client.Email; Mobile = Client.Mobile; StreetName = Client.StreetName; StreetNumber = Client.StreetNumber; ZipCode = Client.ZipCode; City = Client.City; Comment = Client.Comment; Sex = Client.Sex; foreach (ClientCategoryModel categoryModel in Categories) { categoryModel.IsSelected = Client.Categories?.Contains(categoryModel.Category) == true; } _automaticCitySearch = true; } catch (Exception ex) { Logger.Exception(ex); PopupService.DisplayQuestion("Ouverture client", "Le client n'a pu être chargé."); Mediator.Default.Send(new SwitchToSearchClientMessage()); // Switch back to Search Client } finally { IsBusy = false; } }
private void AskVoucherCreationConfirmation() { PopupService.DisplayQuestion("Envoi d'un bon d'achat", "Etes-vous certain(e) de vouloir envoyer un bon d'achat par mail ?", new QuestionActionButton { Caption = "Oui", ClickCallback = async() => await CreateVoucherAsync() //ClickCallback =() => CreateVoucherAsync() }, new QuestionActionButton { Caption = "Non" }); }
private void DeleteClientConfirmed(ClientSummary client) { ClientBL.DeleteClient(client.Id); Clients.Remove(client); PopupService.DisplayQuestion("Confirmation de la suppression", "Le client a été supprimé", QuestionActionButton.Ok()); }
private async Task CreateVoucherAsync() { // Send mail if client has an email try { IsBusy = true; decimal percentage = 20; DateTime maxValidity = DateTime.Today.AddMonths(1); bool byMail = false; if (!string.IsNullOrWhiteSpace(Email)) { await MailSenderBL.SendVoucherMailAsync(Email, FirstName, Sex, percentage, maxValidity); byMail = true; } if (_isUnsavedNewClient) { SaveClient(Client); } Voucher voucher = new Voucher { ClientId = Client.Id, IssueDate = DateTime.Now, Percentage = percentage, ValidityEndDate = maxValidity, }; // Add voucher Client.Vouchers = Client.Vouchers ?? new ObservableCollection <Voucher>(); Client.Vouchers.Add(voucher); Client.VoucherModified(); // Save voucher VoucherBL.SaveVoucher(voucher); // !! this will add voucher to client if not already added // Purchases cannot be deleted anymore foreach (Purchase purchase in Client.Purchases) { purchase.IsPurchaseDeletable = false; } if (byMail) { PopupService.DisplayQuestion("Envoi d'un bon d'achat", $"Le bon a bien été envoyé par mail à l'adresse {Email} et sera valable jusqu'au {maxValidity:dd/MM/yyyy}", QuestionActionButton.Ok()); } else { PopupService.DisplayQuestion("Envoi d'un bon d'achat", $"Un bon d'achat a été émis et sera valable jusqu'au {maxValidity:dd/MM/yyyy}", QuestionActionButton.Ok()); } } catch (Exception ex) { Logger.Exception(ex); PopupService.DisplayError("Envoi d'un bon d'achat", $"Erreur lors de l'envoi du mail à {Email} (numéro de client {Client.ClientBusinessId})"); } finally { IsBusy = false; } }
private void DeletePurchase(Purchase purchase) { PopupService.DisplayQuestion("Suppression d'achat", "Etes-vous certain de vouloir supprimer cet achat?", QuestionActionButton.Yes(() => DeletePurchaseConfirmed(purchase)), QuestionActionButton.No()); }