Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CourseID,OrderID")] GroupShoping groupShoping)
        {
            if (id != groupShoping.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(groupShoping);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupShopingExists(groupShoping.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"] = new SelectList(_context.Courses, "ID", "Text", groupShoping.CourseID);
            ViewData["OrderID"]  = new SelectList(_context.Orders, "ID", "ID", groupShoping.OrderID);
            return(View(groupShoping));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,CourseID,OrderID")] GroupShoping groupShoping)
        {
            if (ModelState.IsValid)
            {
                _context.Add(groupShoping);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"] = new SelectList(_context.Courses, "ID", "Text", groupShoping.CourseID);
            ViewData["OrderID"]  = new SelectList(_context.Orders, "ID", "ID", groupShoping.OrderID);
            return(View(groupShoping));
        }