public ActionResult <RecipeModel> GetRecipe(long id)
        {
            if (id == 0)
            {
                return(BadRequest($"Id was 0"));
            }
            var recipe = _productManagement.LoadRecipe(id);

            if (recipe == null)
            {
                return(NotFound());
            }
            return(ProductConverter.ConvertRecipe(recipe));
        }
        public ActionResult <RecipeModel[]> GetRecipes(long id, int classification)
        {
            var productType = _productManagement.LoadType(id);

            if (productType == null)
            {
                return(BadRequest($"ProductType is null"));
            }
            var recipes      = _productManagement.GetRecipes(productType, (RecipeClassification)classification);
            var recipeModels = new List <RecipeModel>();

            foreach (var recipe in recipes)
            {
                recipeModels.Add(ProductConverter.ConvertRecipe(recipe));
            }
            return(recipeModels.ToArray());
        }
 public ProductManagementController(IProductManagementModification productManagement)
 {
     _productManagement = productManagement;
     _productConverter  = new ProductConverter(_productManagement);
 }
Exemple #4
0
 private async void RecipeChanged(object sender, IRecipe e)
 {
     await _hubContext.Clients.All.SendAsync(nameof(_productManagement.RecipeChanged), ProductConverter.ConvertRecipe(e));
 }