Ejemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("UserId,ProviderID")] User_Provider user_Provider)
        {
            if (id != user_Provider.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user_Provider);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!User_ProviderExists(user_Provider.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProviderID"] = new SelectList(_context.Providers, "ProviderID", "ProviderName", user_Provider.ProviderID);
            ViewData["UserId"]     = new SelectList(_context.Users, "UserId", "UserAddress", user_Provider.UserId);
            return(View(user_Provider));
        }
Ejemplo n.º 2
0
 public IActionResult Create([Bind("UserId,ProviderID")] User_Provider user_Provider)
 {
     if (ModelState.IsValid)
     {
         _context.Add(user_Provider);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["ProviderID"] = new SelectList(_context.Providers, "ProviderID", "ProviderName", user_Provider.ProviderID);
     ViewData["UserId"]     = new SelectList(_context.Users, "UserId", "UserAddress", user_Provider.UserId);
     return(View(user_Provider));
 }