示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,CategoryName")] Category category)
        {
            if (id != category.CategoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.CategoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ItemTypeID,ItemTypeName")] ItemType itemType)
        {
            if (id != itemType.ItemTypeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(itemType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemTypeExists(itemType.ItemTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemType));
        }
        public async Task <IActionResult> Edit(int id, [Bind("LocationID,LocationName")] Location location)
        {
            if (id != location.LocationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(location);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationExists(location.LocationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("ItemID,SerialNo,CategoryID,LocationID,ItemTypeID,ItemName,Vendor,Description,ItemPrice,InstalPrice,Qty,PurchasedDate,InstalDate,RunDate")] Item item)
        {
            if (id != item.ItemID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.ItemID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryName", item.CategoryID);
            ViewData["ItemTypeID"] = new SelectList(_context.ItemTypes, "ItemTypeID", "ItemTypeName", item.ItemTypeID);
            ViewData["LocationID"] = new SelectList(_context.Locations, "LocationID", "LocationName", item.LocationID);
            return(View(item));
        }