public async Task <IActionResult> Edit(int id, [Bind("ShaftId,Ylower,Yupper,North,Xlower,Xupper,East,Subplot")] ShaftLocation shaftLocation) { if (id != shaftLocation.ShaftId) { return(NotFound()); } if (ModelState.IsValid) { try { shaftLocation.Lookup = $"{shaftLocation.Xlower}/{shaftLocation.Xupper} {shaftLocation.North} {shaftLocation.Ylower}/{shaftLocation.Yupper} {shaftLocation.East} {shaftLocation.Subplot}"; _context.Update(shaftLocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShaftLocationExists(shaftLocation.ShaftId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewBag.NorthSouth = new SelectList(CardinalDirections.NorthSouth(), shaftLocation.North); ViewBag.EastWest = new SelectList(CardinalDirections.EastWest(), shaftLocation.East); ViewBag.Subplots = new SelectList(CardinalDirections.SubPlots(), shaftLocation.Subplot); return(View(shaftLocation)); }
public IActionResult Create() { //ViewData["TombId"] = new SelectList(_context.TombLocations, "TombLocationId", "LookupValue", mummy.TombId); ViewBag.NorthSouth = new SelectList(CardinalDirections.NorthSouth()); ViewBag.EastWest = new SelectList(CardinalDirections.EastWest()); ViewBag.Subplots = new SelectList(CardinalDirections.SubPlots()); return(View()); }
public async Task <IActionResult> Create([Bind("ShaftId,Ylower,Yupper,North,Xlower,Xupper,East,Subplot")] ShaftLocation shaftLocation) { if (ModelState.IsValid) { shaftLocation.Lookup = $"{shaftLocation.Xlower}/{shaftLocation.Xupper} {shaftLocation.North} {shaftLocation.Ylower}/{shaftLocation.Yupper} {shaftLocation.East} {shaftLocation.Subplot}"; _context.Add(shaftLocation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.NorthSouth = new SelectList(CardinalDirections.NorthSouth(), shaftLocation.North); ViewBag.EastWest = new SelectList(CardinalDirections.EastWest(), shaftLocation.East); ViewBag.Subplots = new SelectList(CardinalDirections.SubPlots(), shaftLocation.Subplot); return(View(shaftLocation)); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var shaftLocation = await _context.ShaftLocations.FindAsync(id); if (shaftLocation == null) { return(NotFound()); } ViewBag.NorthSouth = new SelectList(CardinalDirections.NorthSouth(), shaftLocation.North); ViewBag.EastWest = new SelectList(CardinalDirections.EastWest(), shaftLocation.East); ViewBag.Subplots = new SelectList(CardinalDirections.SubPlots(), shaftLocation.Subplot); return(View(shaftLocation)); }