Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var signedUserId = _userTable.GetUserId(HttpContext.User.Identity.Name);
            var model        = new TenantViewModel()
            {
                AllUsers        = _userTable.GetAllUsers(),
                AllProject      = _projectTable.GetAllProjects(),
                UsersNotManager = new List <SelectListItem>(),
                Managers        = new List <User>()
            };

            foreach (var user in model.AllUsers)
            {
                if (!await _userMgr.IsInRoleAsync(user, nameof(Roles.Manager)))
                {
                    var text = user.FirstName + " " + user.Surname + " - " + user.Email;
                    model.UsersNotManager.Add(new SelectListItem {
                        Text = text, Value = user.Id.ToString()
                    });
                }
                else if (user.Id != signedUserId)
                {
                    model.Managers.Add(user);
                }
            }

            return(View(model));
        }