예제 #1
0
        public ActionResult DetailsFormation(string nomSeo)
        {
            var vm = new FormationAvecAvisViewModel();

            using (var context = new AvisEntities())
            {
                var formationEntity = context.Formation.Where(f => f.NomSeo == nomSeo).FirstOrDefault();
                if (formationEntity == null)
                {
                    return(RedirectToAction("Accueil", "Home"));
                }

                vm.FormationNom         = formationEntity.Nom;
                vm.FormationDescription = formationEntity.Description;
                vm.FormationNomSeo      = nomSeo;
                vm.FormationUrl         = formationEntity.Url;
                if (formationEntity.Avis.Count > 0)
                {
                    vm.Note = formationEntity.Avis.Average(a => a.Note);
                }
                vm.NombreAvis = formationEntity.Avis.Count;
                vm.Avis       = formationEntity.Avis.OrderByDescending(a => a.DateAvis).ToList();
            }
            return(View(vm));
        }
예제 #2
0
        public ActionResult DetailsFormation(String nomSeo)
        {
            var vm = new FormationAvecAvisViewModel();

            using (var context = new AvisEntities())
            {
                var FormationEntity = context.Formations
                                      .Where(f => f.NomSeo == nomSeo)
                                      .FirstOrDefault();

                if (FormationEntity == null)
                {
                    return(RedirectToAction("Acceuil", "Home"));
                }

                vm.FormationNom         = FormationEntity.Nom;
                vm.FormationDescription = FormationEntity.Description;
                vm.FormationNomSeo      = nomSeo;
                vm.FormationUrl         = FormationEntity.Url;
                vm.Note       = FormationEntity.Avis.Average(a => a.Note);
                vm.NombreAvis = FormationEntity.Avis.Count();
                vm.Avis       = FormationEntity.Avis.ToList();
            }
            return(View(vm));
        }