Esempio n. 1
0
        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"));
            }
        }
Esempio n. 2
0
        // GET: Jedi/Delete/5
        public ActionResult Delete(int id)
        {
            try {
                WebApplicationJedi.ServiceReference.JediWS jedi = null;

                using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
                    jedi = service.getJedis().Find(x => x.Id == id);                     // On tente de le recuperer
                }

                if (jedi != null)                  // Si on l'a eu, on le fait afficher
                {
                    return(View(new JediViewModel(jedi)));
                }
                else                     // Sinon retour a l'index
                {
                    return(RedirectToAction("Index"));
                }
            } catch {             // Les autres erreurs
                return(RedirectToAction("Index"));
            }
        }