public async Task <IActionResult> Create( [Bind("Id,LibraryId,Name,MixTypeId,Instructions,Source")] Recipe recipe, RecipeViewModel recipeVM) { if (ModelState.IsValid) { recipe.Id = Guid.NewGuid(); _context.Add(recipe); await _context.SaveChangesAsync(); foreach (var ingredientVM in recipeVM.IngredientViewModels) { var ingredient = new Ingredient { Id = Guid.NewGuid(), RecipeId = recipe.Id, ComponentId = ingredientVM.ComponentId, Quantity = ingredientVM.Quantity, UnitId = ingredientVM.UnitId, Number = ingredientVM.Number }; _context.Add(ingredient); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(recipe)); }
public async Task<IActionResult> Create([Bind("Id,Name")] Unit unit) { if (ModelState.IsValid) { _context.Add(unit); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(unit); }
public async Task <IActionResult> Create([Bind("Id,Name")] ComponentType componentType) { if (ModelState.IsValid) { _context.Add(componentType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(componentType)); }
public async Task <IActionResult> Create([Bind("Id,RecipeId,ComponentId,Quantity,UnitId,Number")] Ingredient ingredient) { if (ModelState.IsValid) { ingredient.Id = Guid.NewGuid(); _context.Add(ingredient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ingredient)); }
public async Task <IActionResult> Create([Bind("Id,ComponentTypeId,Name,Description")] Component component) { if (ModelState.IsValid) { component.Id = Guid.NewGuid(); _context.Add(component); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(component)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Library library) { if (ModelState.IsValid) { library.Id = Guid.NewGuid(); _context.Add(library); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(library)); }
public async Task GetFlavorWithCorrectId() { var id = Guid.NewGuid(); var flavor = new Flavor { Id = id, Name = "flavor" }; CocktailsContext.Add(flavor); CocktailsContext.SaveChanges(); var result = await _repository.GetSingleAsync(x => x.Where(y => y.Id == id), _token); Assert.IsNotNull(result); Assert.AreEqual(flavor.Id, result.Id); Assert.AreEqual(flavor.Name, result.Name); }