Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("K_AdminId,CustomerId,FirstName,LastName,PhoneNo,Email")] K_Admin k_Admin)
        {
            if (id != k_Admin.K_AdminId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(k_Admin);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!K_AdminExists(k_Admin.K_AdminId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CompanyName", k_Admin.CustomerId);
            return(View(k_Admin));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("K_AdminId,CustomerId,FirstName,LastName,PhoneNo,Email")] K_Admin k_Admin)
        {
            if (ModelState.IsValid)
            {
                _context.Add(k_Admin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CompanyName", k_Admin.CustomerId);
            return(View(k_Admin));
        }