Exemple #1
0
        public ProduitViewModel(SqlContext sqlContext, NotificationService notificationService)
        {
            ContextSql   = sqlContext;
            Notification = notificationService;

            UpdateProduit = new ProduitValidation();
        }
        public async Task OnValidSubmitProduit()
        {
            try
            {
                // Ajout dans la base de donnée.
                await ContextSql.AddProduit(NouveauProduit.ToProduit());

                var produitView = await ContextSql.GetProduits(NouveauProduit.Reference);

                Produits.Add(produitView);

                string message = $"Nouveau produit - ref:{produitView.IdReference} - {produitView.Nom} ajouté";
                NotificationMessage messNotif = new NotificationMessage()
                {
                    Summary  = "Sauvegarde OK",
                    Detail   = message,
                    Duration = 3000,
                    Severity = NotificationSeverity.Success
                };
                Notification.Notify(messNotif);

                Log.Information("PRODUIT - " + message);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "ProduitViewModel - OnValidSubmitProduit");
                Notification.Notify(NotificationSeverity.Error, "Erreur", "Erreur sur la sauvegarde");
            }

            NouveauProduit = new ProduitValidation();
            ImageEnString  = string.Empty;
            HaveImage      = false;
        }
        public ProduitGestionViewModel(SqlContext sqlContext, NotificationService notificationService, NavigationManager navigationManager)
        {
            ContextSql   = sqlContext;
            Notification = notificationService;
            NavManager   = navigationManager;

            NouveauProduit = new ProduitValidation();

            IsLoaded  = false;
            HaveImage = false;
        }
 public void CloseNewProduit()
 {
     CanOpenNewProduit = false;
     NouveauProduit    = new ProduitValidation();
 }