Exemplo n.º 1
0
        public ActionResult Order(int id)
        {
            var recipe         = db.Get(id);
            var priceComputing = new PriceComputing();
            var model          = new OrderViewModel {
                Product = recipe, Price = priceComputing.ComputeRecipePrice(recipe)
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult Details(int Id)
        {
            //return Content(Id.ToString());
            var model = _recipeData.Get(Id);

            if (model == null)
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetRecipe(int id)
        {
            try
            {
                RecipeResult = await recipeData.Get(id);

                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                return(Ok(mapper.Map <RecipeDto>(RecipeResult)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { message = ex.Message }));
            }
        }