Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }