public ActionResult Create(FormCollection collection) {
			try {
				ServiceReference.StadeWS stade = new StadeWS();
				List<CaracteristiqueWS> caracList = new List<CaracteristiqueWS>();

				using(ServiceReference.ServiceClient service = new ServiceClient()) {
					service.getCaracteristiques().ForEach(x => {
						if(x.Type == ServiceReference.ETypeCaracteristiqueWS.Stade) {
							caracList.Add(x);
						}
					});

					/* Item1 parce qu'on a un Tuple */
					stade.Id = 0;
					stade.Planete = Convert.ToString(collection.Get("Item1.Planete"));
					stade.NbPlaces = Convert.ToInt32(collection.Get("Item1.NbPlaces"));
					stade.Caracteristiques = new List<CaracteristiqueWS>();

					string[] checkboxes = collection.GetValues("caracteristiques");
					if(checkboxes != null) {
						foreach(string s in checkboxes) {
							Int32 caracId = Convert.ToInt32(s);
							stade.Caracteristiques.Add(caracList.First(x => x.Id == caracId));
						}
					}

					service.addStade(stade);
				}
				return RedirectToAction("Index");
			} catch {
				return RedirectToAction("Index");
			}
		}
Exemple #2
0
        public void TestServiceGetStades()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();
            List <StadeWS> stades = client.getStades();

            Assert.IsNotNull(stades);
            StadeWS kamino = stades.Find(x => x.Planete.Equals("Kamino"));

            Assert.AreEqual(2, kamino.Caracteristiques.Count);
            Assert.IsNotNull(kamino);
            client.Close();
        }
Exemple #3
0
        public void TestServiceUpdateStades()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List <StadeWS> stades = client.getStades();

            Assert.IsNotNull(stades);
            StadeWS kamino = client.getStades().Find(x => x.Planete.Equals("Kamino"));

            kamino.NbPlaces = 10;
            client.updateStade(kamino);
            Assert.AreEqual(10, ((StadeWS)client.getStades().Find(x => x.Planete.Equals("Kamino"))).NbPlaces);
            kamino.NbPlaces = 100000;
            client.updateStade(kamino);
            Assert.AreEqual(100000, ((StadeWS)client.getStades().Find(x => x.Planete.Equals("Kamino"))).NbPlaces);

            client.Close();
        }
Exemple #4
0
        public void TestServiceARStades()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List <StadeWS> stades = client.getStades();
            int            size   = stades.Count;

            Assert.IsNotNull(stades);
            /* AJOUT */
            StadeWS zone = new StadeWS(0, "Zone TEST", 11, new List <CaracteristiqueWS>());

            client.addStade(zone);
            Assert.AreEqual(size + 1, client.getStades().Count);
            /* SUPPRESSION */
            zone = client.getStades().Find(x => x.Planete.Equals("Zone TEST"));
            client.removeStade(zone);
            Assert.AreEqual(size, client.getStades().Count);

            client.Close();
        }
Exemple #5
0
        public ActionResult Create(FormCollection collection)
        {
            try {
                ServiceReference.StadeWS stade     = new StadeWS();
                List <CaracteristiqueWS> caracList = new List <CaracteristiqueWS>();

                using (ServiceReference.ServiceClient service = new ServiceClient()) {
                    service.getCaracteristiques().ForEach(x => {
                        if (x.Type == ServiceReference.ETypeCaracteristiqueWS.Stade)
                        {
                            caracList.Add(x);
                        }
                    });

                    /* Item1 parce qu'on a un Tuple */
                    stade.Id               = 0;
                    stade.Planete          = Convert.ToString(collection.Get("Item1.Planete"));
                    stade.NbPlaces         = Convert.ToInt32(collection.Get("Item1.NbPlaces"));
                    stade.Caracteristiques = new List <CaracteristiqueWS>();

                    string[] checkboxes = collection.GetValues("caracteristiques");
                    if (checkboxes != null)
                    {
                        foreach (string s in checkboxes)
                        {
                            Int32 caracId = Convert.ToInt32(s);
                            stade.Caracteristiques.Add(caracList.First(x => x.Id == caracId));
                        }
                    }

                    service.addStade(stade);
                }
                return(RedirectToAction("Index"));
            } catch {
                return(RedirectToAction("Index"));
            }
        }