public IActionResult DetailsFormations(string idFormation) { int iIdFormation = -1; if (!Int32.TryParse(idFormation, out iIdFormation)) { return(RedirectToAction("ToutesLesFormations")); } var formation = _repository.GetFormationById(iIdFormation); if (formation == null) { return(RedirectToAction("ToutesLesFormations")); } var vm = new DetailFormationViewModel(); vm.Formation = formation; if (formation.Avis != null && formation.Avis.Count > 0) { vm.NoteMoyenne = formation.Avis.Select(a => a.Note).ToList().Average(); } return(View(vm)); }
public IActionResult LaisserUnAvis(string idFormation) { int iIdFormation = -1; if (!Int32.TryParse(idFormation, out iIdFormation)) { return(RedirectToAction("ToutesLesFormations", "Formation")); } var formation = _repository.GetFormationById(iIdFormation); if (formation == null) { return(RedirectToAction("ToutesLesFormations", "Formation")); } var vm = new LaisserUnAvisViewModel(); vm.NomFormation = formation.Nom; vm.IdFormation = formation.Id.ToString(); return(View(vm)); }