Пример #1
0
        public static Jedi JediContractToJedi(JediContract j)
        {
            Jedi jedi = new Jedi();

            jedi.ID     = j.ID;
            jedi.Nom    = j.Nom;
            jedi.IsSith = j.IsSith;
            return(jedi);
        }
Пример #2
0
        public ActionResult Delete(int id, JediContract jedi)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.DelJedis(jedi);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #3
0
        public ActionResult Create(JediContract jedi)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.AddJedis(jedi);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
        public ActionResult Delete(int id, JediContract jedi)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.DelJedis(jedi);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #5
0
        public ActionResult Create(JediContract jedi)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.AddJedis(jedi);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #6
0
        /// <summary>
        /// Adapte un Jedi Model en Jedi Contract.
        /// </summary>
        /// <param name="jedi">Jedi à adapter.</param>
        /// <returns>Jedi contract.</returns>
        public static JediContract fromJediModel(JediModel jedi)
        {
            if (jedi == null)
                return null;

            JediContract jc = new JediContract();
            jc.ID = jedi.ID;
            jc.Nom = jedi.Nom;
            jc.IsSith = jedi.IsSith;

            if (jedi.Caracteristiques == null)
                jedi.Caracteristiques = new List<CaracteristiqueModel>();

            jc.Caracteristiques = CaracteristiqueAdapter.fromCaracteristiqueModelList(jedi.Caracteristiques).ToArray();

            return jc;
        }
Пример #7
0
        /// <summary>
        /// Adapte un Jedi Contract en Jedi Model.
        /// </summary>
        /// <param name="jediC">Jedi Contract à adapter.</param>
        /// <returns>Jedi Model.</returns>
        public static JediModel fromJediContract(JediContract jediC)
        {
            if (jediC == null)
                return null;

            JediModel j = new JediModel();
            j.ID = jediC.ID;
            j.Nom = jediC.Nom;
            j.IsSith = jediC.IsSith;

            if (jediC.Caracteristiques == null)
                jediC.Caracteristiques = new CaracteristiqueContract[0];

            j.Caracteristiques = CaracteristiqueAdapter.fromCaracteristiqueContractList(jediC.Caracteristiques.ToList());

            return j;
        }
        public void TestCreateJedi()
        {
            JediWebServiceClient client = new JediWebServiceClient();

            JediContract[] jedisBegin = client.GetJedis();
            Assert.IsNotNull(jedisBegin);

            // Test de création de jedi
            JediContract jedi1 = new JediContract();
            jedi1.Nom = "Test_1";
            jedi1.IsSith = false;

            CaracteristiqueContract[] caracs1 = new CaracteristiqueContract[1];
            caracs1[0] = new CaracteristiqueContract();
            jedi1.Caracteristiques = caracs1;
            client.CreateJedi(jedi1);

            // Vérifie que le jedi a bien été créé
            JediContract[] jedisMid = client.GetJedis();
            Assert.IsNotNull(jedisMid);
            Assert.AreEqual(jedisBegin.Length + 1, jedisMid.Length);

            int index = jedisMid.Length - 1;
            // Test du jedi ajouté
            Assert.AreEqual(jedisMid[index].Nom, "Test_1");
            Assert.AreEqual(jedisMid[index].IsSith, false);
            Assert.IsNotNull(jedisMid[index].Caracteristiques);
            Assert.AreEqual(jedisMid[index++].Caracteristiques.Length, 1);

            // Test de création de jedi
            JediContract jedi2 = new JediContract();
            jedi2.Nom = "Test_2";
            jedi2.IsSith = true;
            client.CreateJedi(jedi2);

            // Vérifie que le jedi a bien été créé
            JediContract[] jedisEnd = client.GetJedis();
            Assert.IsNotNull(jedisEnd);
            Assert.AreEqual(jedisMid.Length + 1, jedisEnd.Length);

            // Test du jedi ajouté
            Assert.AreEqual(jedisEnd[index].Nom, "Test_2");
            Assert.AreEqual(jedisEnd[index].IsSith, true);
            Assert.IsNull(jedisEnd[index++].Caracteristiques);
        }
Пример #9
0
 public void UpdateJedis(JediContract jedi)
 {
     jtm.UpdateJedi(JediAdapter.JediContractToJedi(jedi));
 }
Пример #10
0
 public void DelJedis(JediContract jedi)
 {
     jtm.DelJedi(JediAdapter.JediContractToJedi(jedi));
 }
Пример #11
0
 public JediContract AddJedis(JediContract jedi)
 {
     jtm.AddJedi(JediAdapter.JediContractToJedi(jedi));
     return(jedi);
 }
Пример #12
0
        public void TestGetCaracsFromJedi()
        {
            JediWebServiceClient client = new JediWebServiceClient();

            JediContract[] jedis = client.GetJedis();

            // Test get carac de jedi du web service
            if (jedis.Length > 0)
            {
                // Jedi Darth Vador
                CaracteristiqueContract[] caracs0 = client.GetCaracteristiques(jedis[0].ID);
                Assert.IsNotNull(caracs0);
                Assert.AreEqual(caracs0.Length, 3);

                // Jedi Count Dooku
                CaracteristiqueContract[] caracs1 = client.GetCaracteristiques(jedis[1].ID);
                Assert.IsNull(caracs1);

                // Nouveau Jedi
                JediContract newJedi1 = new JediContract();
                newJedi1.Nom = "Test 1";
                newJedi1.IsSith = false;
                CaracteristiqueContract[] caracs = new CaracteristiqueContract[1];
                caracs[0] = new CaracteristiqueContract();
                newJedi1.Caracteristiques = caracs;

                CaracteristiqueContract[] caracs3 = client.GetCaracteristiques(newJedi1.ID);
                Assert.IsNull(caracs3);
            }
        }