Ejemplo n.º 1
0
        public RackViewModel(SqlContext sqlContext, NotificationService notificationService)
        {
            IsLoaded            = false;
            SqlContext          = sqlContext;
            DialogIsOpenNewRack = false;
            NotificationService = notificationService;

            NouveauRack = new RackValidation();
        }
Ejemplo n.º 2
0
        /// <see cref="IClientViewModel.OnValidSubmit"/>
        public async void OnValidSubmit()
        {
            try
            {
                // Si contient déjà le gisement et la position.
                if (AllRacks.Any(x => x.Gisement == NouveauRack.Gisement &&
                                 x.PosRack == NouveauRack.Position))
                {
                    string msgWarn = $"Aucun ajout : {NouveauRack.Gisement} - {NouveauRack.Position} existe déjà";
                    NotificationMessage messWarn = new NotificationMessage()
                    {
                        Summary  = "Attention",
                        Detail   = msgWarn,
                        Duration = 3000,
                        Severity = NotificationSeverity.Warning
                    };
                    NotificationService.Notify(messWarn);

                    return;
                }

                // Ajout dans la base de donnée.
                int idRack = await SqlContext.AddRack(NouveauRack.Gisement, NouveauRack.Position);

                Rack nouveauRack = new Rack()
                {
                    IdRack   = idRack,
                    Gisement = NouveauRack.Gisement,
                    PosRack  = NouveauRack.Position
                };

                AllRacks.Add(nouveauRack);
                await RackGrid.Reload();

                string message = $"Nouveau rack : {nouveauRack.Gisement} ajouté";
                NotificationMessage messNotif = new NotificationMessage()
                {
                    Summary  = "Sauvegarde OK",
                    Detail   = message,
                    Duration = 3000,
                    Severity = NotificationSeverity.Success
                };
                NotificationService.Notify(messNotif);

                Log.Information("RACK - " + message);

                NouveauRack = new RackValidation();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "RackViewModel - OnValidSubmit");
            }
        }
Ejemplo n.º 3
0
 /// <see cref="IClientViewModel.CloseNouveauClient"/>
 public void CloseNouveauRack()
 {
     DialogIsOpenNewRack = false;
     NouveauRack         = new RackValidation();
 }