Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductoId,tagId")] tag_prod tag_prod)
        {
            if (id != tag_prod.ProductoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tag_prod);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tag_prodExists(tag_prod.ProductoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoId"] = new SelectList(_context.productos, "ProductoId", "descripcionProd", tag_prod.ProductoId);
            ViewData["tagId"]      = new SelectList(_context.tags, "tagId", "nomTag", tag_prod.tagId);
            return(View(tag_prod));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ProductoId,tagId")] tag_prod tag_prod)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tag_prod);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoId"] = new SelectList(_context.productos, "ProductoId", "descripcionProd", tag_prod.ProductoId);
            ViewData["tagId"]      = new SelectList(_context.tags, "tagId", "nomTag", tag_prod.tagId);
            return(View(tag_prod));
        }