private static async Task ProcessRecipeAsync(RecipeController recCont, RecipeStepController rsCont, NavigationController navig) { NavigatorItem item = NavigatorItem.Recipe; Category targetCategory = SetTargetCategory(navig, item); Recipe recipeToAdd; bool result = false; recipeToAdd = FormRecipe(recCont); recCont.SetCategoryInRecipe(targetCategory, recipeToAdd); try { result = await recCont.TryCreateRecipeAsync(recipeToAdd); } catch (Exception) { Console.WriteLine("Creating recipe is not possible!"); Console.ReadKey(); return; } if (result) { await rsCont.AddStepsAsync(GatherSteps(recipeToAdd)); await FormIngredientListAsync(recipeToAdd, recCont); await navig.UpdateSubItems(); Console.WriteLine("Recipe created succesfully!"); } }
public RecipeStepControllerTests() { _unitOfWork = new Mock <IUnitOfWork>(); _mockRepository = new Mock <IRepository>(); _loggerMock = new Mock <ILogger <RecipeStepController> >(); _unitOfWork.SetupGet(u => u.Repository).Returns(_mockRepository.Object); _recipeStepController = new RecipeStepController(_unitOfWork.Object, _loggerMock.Object); }
public EditModel(RecipeController recipeController, MeasureController measureController, CategoryController categoryController, IngredientDetailController ingredientDetailController, RecipeStepController recipeStepController) { _recipeController = recipeController; _measureController = measureController; _categoryController = categoryController; _ingredientDetailController = ingredientDetailController; _recipeStepController = recipeStepController; }
static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); _logger = host.Services.GetRequiredService <ILogger <Program> >(); RecipeController recCont = host.Services.GetRequiredService <RecipeController>(); CategoryController catCont = host.Services.GetRequiredService <CategoryController>(); RecipeStepController rsCont = host.Services.GetRequiredService <RecipeStepController>(); NavigationController navig = host.Services.GetRequiredService <NavigationController>(); await navig.StartNavigator(); while (true) { WriteNavigator(navig); MenuStart(); string input = Console.ReadLine().ToLower().Trim(); if (input == "exit") { break; } int option; if (int.TryParse(input, out option)) { await ProcessNumberAsync(option, navig); } else if (input == "addrecipe") { await ProcessRecipeAsync(recCont, rsCont, navig); } else if (input == "addcategory") { await ProcessCategoryAsync(catCont, navig); } else { Console.WriteLine("Unknown instruction!"); Console.ReadKey(); } } }