public async Task <ActionResult> Liste() { List <Parametrage> _bddParam = await db.Parametrages.ToListAsync(); List <ParametrageViewModel> _param = new List <ParametrageViewModel>(); foreach (var p in _bddParam) { ParametrageViewModel param = new ParametrageViewModel(p); _param.Add(param); } return(View(_param)); }
public async Task <ActionResult> Create([Bind(Include = "ID,Cle,Valeur,Type,Details")] ParametrageViewModel paramToCreate) { if (ModelState.IsValid) { Parametrage bddParamToCreate = new Parametrage { ID = paramToCreate.ID, Cle = paramToCreate.Cle, Valeur = paramToCreate.Valeur, Type = paramToCreate.Type, Details = paramToCreate.Details }; db.Parametrages.Add(bddParamToCreate); await db.SaveChangesAsync(); return(RedirectToAction("Liste")); } return(View(new ParametrageViewModel())); }
// GET: Parametrages/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Parametrage bddParam = await db.Parametrages.FindAsync(id); if (bddParam == null) { return(HttpNotFound()); } ParametrageViewModel detailsParam = new ParametrageViewModel(bddParam); return(View(detailsParam)); }