Example #1
0
        public void DeleteItem(Guid id)
        {
            var compositions = CompositionRepository.GetList().Where(x => x.RecipeId == id).ToList();

            compositions.ForEach(x => CompositionRepository.Delete(x.Id));

            var reviews = ReviewRepository.GetList().Where(x => x.RecipeId == id).ToList();

            reviews.ForEach(x => ReviewRepository.Delete(x.Id));

            RecipeRepository.Delete(id);
        }
Example #2
0
        public RecipeModel GetItem(Guid id)
        {
            var temp     = RecipeRepository.GetItem(id);
            var tempIngr = IngredientRepository.GetList();
            var tempComp = CompositionRepository.GetList().Where(y => y.RecipeId == temp.Id).Select(CompositionMapper.ConvertCompositonToCompositionModel).ToList();

            tempComp.ForEach(y => y.IngredientName = tempIngr.Where(z => z.Id == y.IngredientId).FirstOrDefault()?.Name);

            return(new RecipeModel
            {
                Id = temp.Id,
                Category = (Enums.CategoryTypes)temp.Category,
                Name = temp.Name,
                Composition = tempComp,
                Review = ReviewRepository.GetList().Where(y => y.Id == temp.Id).Select(ReviewMapper.ConvertReviewToReviewModel).ToList(),
                User = UserMapper.ConvertUserToUserModel(UserRepository.GetList().FirstOrDefault())
            });
        }