Example #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,Price")] Item item)
        {
            if (ModelState.IsValid)
            {
                _context.Add(item);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Example #2
0
        public async Task <List <Item> > Add(Item item)
        {
            Item tempItem = new Item();

            tempItem.Category = "Los Angeles Lakers";
            tempItem.Name     = "Kobe Bryant";
            tempItem.Price    = 81;
            tempItem.Id       = 0;

            _context.Item.Add(tempItem);
            await _context.SaveChangesAsync();

            return(await _context.Item.ToListAsync());
        }