public async Task <IActionResult> Edit(int id, [Bind("Id,SizeId,ColorId,ModelId")] SizeColorModel sizeColorModel) { if (id != sizeColorModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sizeColorModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SizeColorModelExists(sizeColorModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ColorId"] = new SelectList(_context.Colors, "Id", "ColorName", sizeColorModel.ColorId); ViewData["ModelId"] = new SelectList(_context.BicycleModels, "Id", "ModelName", sizeColorModel.ModelId); ViewData["SizeId"] = new SelectList(_context.Sizes, "Id", "SizeName", sizeColorModel.SizeId); return(View(sizeColorModel)); }
public async Task <IActionResult> GoToBicycles(int?id) { SizeColorModel model = _context.SizeColorModels.Where(b => b.Id == id).FirstOrDefault(); RedirectToActionResult redirectToActionResult = RedirectToAction("Index", "Bicycles", new { size = model.SizeId, color = model.ColorId, model = model.ModelId }); return(await Task.Run <IActionResult>(() => { return redirectToActionResult; })); }
public async Task <IActionResult> Create([Bind("Id,SizeId,ColorId,ModelId")] SizeColorModel sizeColorModel) { if (ModelState.IsValid) { _context.Add(sizeColorModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ColorId"] = new SelectList(_context.Colors, "Id", "ColorName", sizeColorModel.ColorId); ViewData["ModelId"] = new SelectList(_context.BicycleModels, "Id", "ModelName", sizeColorModel.ModelId); ViewData["SizeId"] = new SelectList(_context.Sizes, "Id", "SizeName", sizeColorModel.SizeId); return(View(sizeColorModel)); }