コード例 #1
0
        public async Task <IActionResult> Create([Bind("CategoryID,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ItemTypeID,ItemTypeName")] ItemType itemType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(itemType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(itemType));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("LocationID,LocationName")] Location location)
        {
            if (ModelState.IsValid)
            {
                _context.Add(location);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("ItemID,SerialNo,CategoryID,LocationID,ItemTypeID,ItemName,Vendor,Description,ItemPrice,InstalPrice,Qty,PurchasedDate,InstalDate,RunDate")] Item item)
        {
            if (ModelState.IsValid)
            {
                _context.Add(item);
                await _context.SaveChangesAsync();

                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));
        }