/// <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; }
/// <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 ActionResult Create(FormCollection collection) { try { // Récupère les valeurs du formulaire soumis string name = collection["Nom"]; bool isSith = false; bool.TryParse(collection["IsSith"], out isSith); // Nouveau Jedi JediModel newJedi = new JediModel(); newJedi.Nom = name; newJedi.IsSith = isSith; // Appèle le Web Service pour l'enregistrement m_webService.CreateJedi(JediAdapter.fromJediModel(newJedi)); return new RedirectResult(Url.Action("Index") + "#content"); } catch { return View(); } }