Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonInOrder1,PersonId,OrderId,Type")] PersonInOrder personInOrder)
        {
            if (id != personInOrder.PersonInOrder1)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(personInOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonInOrderExists(personInOrder.PersonInOrder1))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]  = new SelectList(_context.Order, "OrderId", "OrderGuid", personInOrder.OrderId);
            ViewData["PersonId"] = new SelectList(_context.PersonalInfo, "PersonalInfoId", "FirstName", personInOrder.PersonId);
            return(View(personInOrder));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("PersonInOrder1,PersonId,OrderId,Type")] PersonInOrder personInOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personInOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]  = new SelectList(_context.Order, "OrderId", "OrderGuid", personInOrder.OrderId);
            ViewData["PersonId"] = new SelectList(_context.PersonalInfo, "PersonalInfoId", "FirstName", personInOrder.PersonId);
            return(View(personInOrder));
        }