Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateUsers(AppUserVM appUserVM, AppUserRoleVM appUserRoleVM)
        {
            var    appUserModelMVC = new AppUserModelMVC();
            string token           = HttpContext.Session.GetString("token_access");
            var    list            = await _userRoleServiceApiClient.GetAll(token);

            appUserModelMVC.ListAppUserRoleVM = list;
            appUserModelMVC.appUserRoleVM     = appUserRoleVM;
            appUserModelMVC.appUserVM         = appUserVM;
            return(View(appUserModelMVC));
        }
Ejemplo n.º 2
0
        public async Task <List <AppUserModelMVC> > GetAll(string token)
        {
            var client = _httpClientFactory.CreateClient();

            client.BaseAddress = new Uri(_configuration["UrlApi"]);
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            var response = await client.GetAsync("/api/users");

            var body = await response.Content.ReadAsStringAsync();

            var appuserVM     = JsonConvert.DeserializeObject <List <AppUserVM> >(body);
            var appuserroleVM = await _userRoleServiceApiClient.GetAll(token);

            var list = (from _user in appuserVM
                        join _userrole in appuserroleVM on _user.AppUserRolesId equals _userrole.Id into userroles
                        from _userroles in userroles.DefaultIfEmpty()
                        select new AppUserModelMVC
            {
                appUserRoleVM = _userroles,
                appUserVM = _user
            }).ToList();

            return(list);
        }