Esempio n. 1
0
        public void TestAddPrime()
        {
            List <User> lst = clientService.SearchUser("del");



            if (lst.Count >= 1)
            {
                User me = lst[0];

                Prime prime = new Prime()
                {
                    User_id   = me.Id,
                    Price     = 2000,
                    StartDate = DateTime.Now,
                    EndDate   = DateTime.Now,
                    Label     = "Yolo prime"
                };

                Assert.IsTrue(clientService.addPrime(me.Id, prime));

                lst = clientService.SearchUser("del");
                me  = lst[0];

                int nbPrime = clientService.GetPrimesByUserId(me.Id).Count;

                Assert.AreEqual(me.Primes.Count, nbPrime);
            }
        }
Esempio n. 2
0
 private void OnAddPrimeButtonClick(string s)
 {
     try
     {
         decimal primePrice = decimal.Parse(InputPrimePrice);
         if (InputPrimeName == string.Empty || InputPrimeEnd < DateTime.Now)
         {
             throw new ArgumentNullException();
         }
         var newPrime = new Prime
         {
             Label     = InputPrimeName,
             Price     = primePrice,
             StartDate = DateTime.Now,
             EndDate   = InputPrimeEnd
         };
         var userId = Employee.Id;
         ServiceSalaire.addPrime(userId, newPrime);
         // Update the employee
         Employee = ServiceSalaire.GetUserById(userId);
     }
     catch (ArgumentNullException)
     {
         MessageBox.Show("Les paramètres sont invalides, recommencer", "Erreur de paramètres",
                         MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (FormatException)
     {
         MessageBox.Show("Merci d'indiquer un nombre pour le montant.", "Erreur de montant", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
     catch (Exception)
     {
         MessageBox.Show("Le service n'est pas disponible pour le moment", "Service non disponible",
                         MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }