示例#1
0
        // GET: IngredientViewModels
        public ActionResult Index()
        {
            var ingredientsList             = _ingredientManager.GetAll();
            var listOfIngredientsViewModels = _mapper.Map <IList <IngredientViewModel> >(ingredientsList);

            return(View(listOfIngredientsViewModels));
        }
示例#2
0
        // GET: Recipe/Create
        public ActionResult Create()
        {
            var newRecipe = new RecipeIngredientsViewModel();

            var dropDownListOfIngredientModels = _ingredientManager.GetAll();
            var dropDownListOfIngrediens       = _mapper.Map <List <IngredientViewModel> >(dropDownListOfIngredientModels);

            newRecipe.IngredientsDropDownList = dropDownListOfIngrediens;

            return(View(newRecipe));
        }
 public IActionResult GetAll()
 {
     try
     {
         return(Ok(_ingredientManager.GetAll()));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }