public ActionResult Delete(int id, FormCollection collection) { try { using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) { WebApplicationJedi.ServiceReference.JediWS jedi = null; jedi = service.getJedis().Find(x => x.Id == id); // On tente de le recuperer if (jedi != null) // Si on l'a eu, on le supprime { service.removeJedi(jedi); } } return(RedirectToAction("Index")); } catch { return(RedirectToAction("Index")); } }
public void TestServiceARJedis() { ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); List<JediWS> jedis = client.getJedis(); int size = jedis.Count; Assert.IsNotNull(jedis); /* AJOUT */ JediWS bob = new JediWS(0, "Bob THE TEST", true, new List<CaracteristiqueWS>()); client.addJedi(bob); Assert.AreEqual(size+1, client.getJedis().Count); /* SUPPRESSION */ bob = client.getJedis().Find(x => x.Nom.Equals("Bob THE TEST")); client.removeJedi(bob); Assert.AreEqual(size, client.getJedis().Count); client.Close(); }
public ActionResult Delete(int id, FormCollection collection) { try { using(ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) { WebApplicationJedi.ServiceReference.JediWS jedi = null; jedi = service.getJedis().Find(x => x.Id == id); // On tente de le recuperer if(jedi != null) { // Si on l'a eu, on le supprime service.removeJedi(jedi); } } return RedirectToAction("Index"); } catch { return RedirectToAction("Index"); } }