Exemplo n.º 1
0
        public JsonResult Get()
        {
            List <Object>           recettes   = _ngCookingRepository.GetAll <Recette>(_recette).ToList();
            List <RecetteViewModel> recettesVM = new List <RecetteViewModel>();

            foreach (Recette recette in recettes)
            {
                List <Ingredient> recetteIngredients = _ngCookingRepository.GetIngredientsByRecetteId(recette.Id).ToList();
                List <Comment>    recetteComments    = _ngCookingRepository.GetCommentsByRecetteId(recette.Id).ToList();
                var recetteVM = Mapper.Map <RecetteViewModel>(recette);
                _logger.LogInformation("Le mappage est fait");
                recetteVM.Ingredients = new List <Ingredient>();
                recetteVM.Comments    = new List <Comment>();
                //formattage de ingredients
                foreach (Ingredient ingredient in recetteIngredients)
                {
                    recetteVM.Ingredients.Add((Ingredient)_ngCookingRepository.FindById(ingredient.Id, "Ingredient"));
                }
                //formattage de comments
                foreach (Comment comment in recetteComments)
                {
                    recetteVM.Comments.Add(comment);
                }
                recettesVM.Add(recetteVM);
            }
            _logger.LogInformation($"ça marhe pour les recettesVM:{recettesVM.Count}");
            return(Json(recettesVM));
        }
Exemplo n.º 2
0
        public JsonResult Get()
        {
            var communautes = _ngCookingRepository.GetAll <Communaute>(_communaute);
            ICollection <CommunauteViewModel> communautesVM = new List <CommunauteViewModel>();

            foreach (Communaute communaute in communautes)
            {
                var communauteVM = Mapper.Map <CommunauteViewModel>(communaute);
                communautesVM.Add(communauteVM);
            }
            return(Json(communautesVM));
        }
Exemplo n.º 3
0
 public JsonResult Get()
 {
     return(Json(_ngCookingRepository.GetAll <Ingredient>(_ingredient)));
 }
Exemplo n.º 4
0
 public JsonResult Get()
 {
     return(Json(_ngCookingRepository.GetAll <Comment>(_comment)));
 }
Exemplo n.º 5
0
 public JsonResult Get()
 {
     return(Json(_ngCookingRepository.GetAll <Category>(_category)));
 }