public RecipeType(StepRepository stepRepository) { Field(t => t.RecipeId); Field(t => t.Name); Field <ListGraphType <StepType> >(nameof(Recipe.Steps), resolve: context => stepRepository.GetByRecipeId(context.Source.RecipeId)); }
public UnitOfWork(DataContext context) { _context = context; Tutorials = new TutorialRepository(_context); Users = new UserRepository(_context); Languages = new LanguageRepository(_context); TutorialSteps = new TutorialStepRepository(_context); Steps = new StepRepository(_context); }
public RamblesController(ApplicationDbContext context, OpinionRepository opinionRepository, RambleRepository rambleRepository, StepRepository stepRepository, UserManager <User> userManager) { _context = context; _opinionRepository = opinionRepository; _rambleRepository = rambleRepository; _stepRepository = stepRepository; _userManager = userManager; }
public GlobalQuery(IngredientRepository ingredientRepository, StepRepository stepRepository, RecipeRepository recipeRepository) { Field <ListGraphType <IngredientType> >("ingredients", resolve: context => ingredientRepository.GetAll()); Field <ListGraphType <StepType> >("steps", resolve: context => stepRepository.GetAll()); Field <ListGraphType <RecipeType> >("recipes", resolve: context => recipeRepository.GetAll()); Field <RecipeType>( nameof(Recipe), arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = nameof(Recipe.RecipeId) }), resolve: (context) => { var recipeId = context.GetArgument <long>("recipeId"); return(recipeRepository.GetRecipeById(recipeId)); }); }
public FormSettings() { this.repo = new StepRepository(Settings.Default); InitializeComponent(); Init(); }
public UnitOfWork(ItemsContext context) { _context = context; Steps = new StepRepository(_context); Items = new ItemRepository(_context); }
public async Task <Recipe> CreateAsync(Recipe recipe) { if (string.IsNullOrEmpty(recipe.Notes)) { recipe.Notes = "No Notes Yet."; } // TODO: Extract this out to a function of its own. if (string.IsNullOrEmpty(recipe.CreatedBy) || string.IsNullOrEmpty(recipe.ModifiedBy)) { recipe.CreatedBy = await SecurityService.GetCurrentUserName(); recipe.ModifiedBy = await SecurityService.GetCurrentUserName(); } var existingRecipe = await RecipeRepository.GetByKeyAsync(recipe.Key); if (existingRecipe != null && existingRecipe.CreatedBy == recipe.CreatedBy) { throw new BistroFiftyTwoDuplicateRecipeException( "A recipe with that key already exists. Edit the existing recipe instead."); //TODO: Once we have update, call update instead. } var createdRecipe = await RecipeRepository.CreateAsync(recipe); var recipeIngredientTasks = new List <Task <RecipeIngredient> >(); var recipeStepTasks = new List <Task <Step> >(); recipe.Ingredients.ToList().ForEach(async r => { r.RecipeId = createdRecipe.ID; if (string.IsNullOrEmpty(r.Notes)) { r.Notes = $"Notes for ingredient {r.Ordinal}"; } if (string.IsNullOrEmpty(r.Units)) { r.Units = "items"; } if (string.IsNullOrEmpty(r.CreatedBy) || string.IsNullOrEmpty(r.ModifiedBy)) { r.CreatedBy = await SecurityService.GetCurrentUserName(); r.ModifiedBy = await SecurityService.GetCurrentUserName(); } await RecipeIngredientRepository.CreateAsync(r); }); recipe.Steps.ToList().ForEach(async s => { s.RecipeId = createdRecipe.ID; if (string.IsNullOrEmpty(s.CreatedBy) || string.IsNullOrEmpty(s.ModifiedBy)) { s.CreatedBy = await SecurityService.GetCurrentUserName(); s.ModifiedBy = await SecurityService.GetCurrentUserName(); } await StepRepository.CreateAsync(s); }); // set the historical version correctly. - may need to do more work here for revisions, set version correctly. var recipeHistory = await RecipeHistoryRepository.GetAsync(recipe.FullTextReference); recipeHistory.RecipeID = createdRecipe.ID; await RecipeHistoryRepository.UpdateAsync(recipeHistory); // pull the recipe from the db which also will populate the cache. return(await GetByIdAsync(createdRecipe.ID)); }
private async Task PopulateSteps(Recipe recipe) { recipe.Steps = await StepRepository.GetByRecipeIdAsync(recipe.ID); }
public StepsController() { _dataContext = new DataContext(); _repository = new StepRepository(_dataContext); _stepQuery = new StepQuery(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); }