Exemplo n.º 1
0
        // GET: Employee
        public IActionResult Index()
        {
            var identityRoles = _context.Roles.ToList();
            var roleEmployee  = _context.Roles.Single(x => x.Name == RoleNames.Employee);
            var model         = _context.ApplicationUser.Include(x => x.Roles)
                                .Where(x => x.Roles.Any(r => r.RoleId == roleEmployee.Id))
                                .ToList()
                                .Select(x => EmployeeEditViewModel.CreateForEdit(x, identityRoles, _context.Cities.ToList())).ToList();

            return(View(model));
        }
Exemplo n.º 2
0
        // GET: Employee/Edit/5
        public IActionResult Edit(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            ApplicationUser applicationUser = _context.ApplicationUser.GetById(id);

            if (applicationUser == null)
            {
                return(HttpNotFound());
            }

            var roles    = _context.Roles.ToList();
            var cityList = _context.Cities.ToList();

            return(View(EmployeeEditViewModel.CreateForEdit(applicationUser, roles, cityList)));
        }