Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,RoleGroupId")] UserRoleGroups userRoleGroups)
        {
            if (id != userRoleGroups.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userRoleGroups);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserRoleGroupsExists(userRoleGroups.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleGroupId"] = new SelectList(_context.RoleGroups, "Id", "Name", userRoleGroups.RoleGroupId);
            ViewData["UserId"]      = new SelectList(_context.Users, "Id", "Name", userRoleGroups.UserId);
            return(View(userRoleGroups));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,UserId,RoleGroupId")] UserRoleGroups userRoleGroups)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userRoleGroups);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleGroupId"] = new SelectList(_context.RoleGroups, "Id", "Name", userRoleGroups.RoleGroupId);
            ViewData["UserId"]      = new SelectList(_context.Users, "Id", "Name", userRoleGroups.UserId);
            return(View(userRoleGroups));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            UserRoleGroups = await _context.UserRoleGroups.FindAsync(id);

            if (UserRoleGroups != null)
            {
                _context.UserRoleGroups.Remove(UserRoleGroups);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            UserRoleGroups = await _context.UserRoleGroups
                             .Include(u => u.RoleGroup)
                             .Include(u => u.User).FirstOrDefaultAsync(m => m.UserId == id);

            if (UserRoleGroups == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            UserRoleGroups = await _context.UserRoleGroups
                             .Include(u => u.RoleGroup)
                             .Include(u => u.User).FirstOrDefaultAsync(m => m.UserId == id);

            if (UserRoleGroups == null)
            {
                return(NotFound());
            }
            ViewData["RoleGroupId"] = new SelectList(_context.RoleGroups, "Id", "Name");
            ViewData["UserId"]      = new SelectList(_context.Users, "Id", "Email");
            return(Page());
        }