Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ProductID,Name")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("OfferName")] Offer offer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(offer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(offer));
        }
        public async Task <IActionResult> Create([Bind("OfferProductID,OfferName,ProductID")] OfferProduct offerProduct)
        {
            if (ModelState.IsValid)
            {
                _context.Add(offerProduct);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OfferName"] = new SelectList(_context.Offer, "OfferName", "OfferName", offerProduct.OfferName);
            ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductID", offerProduct.ProductID);
            return(View(offerProduct));
        }
 public async Task Add(Product product)
 {
     _codeTestContext.Products.Add(product);
     _codeTestContext.Entry(product).State = EntityState.Added;
     await _codeTestContext.SaveChangesAsync();
 }
Exemplo n.º 5
0
 public async Task Add(Category category)
 {
     _codeTestContext.Categories.Add(category);
     _codeTestContext.Entry(category).State = EntityState.Added;
     await _codeTestContext.SaveChangesAsync();
 }