public async Task <IViewComponentResult> InvokeAsync() { string companyName = _configuration.GetSection("AppSettings").GetSection("CompanyName").Value; LoginModelExtension modelView = new LoginModelExtension(); ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; if (principal != null) { var f_shiiresaki_mei = principal?.Claims.FirstOrDefault(c => c.Type == "f_shiiresaki_mei"); if (f_shiiresaki_mei != null) { companyName = f_shiiresaki_mei.Value; } } if (principal != null) { modelView.UserName = HttpContext.User.Identity.Name; modelView.Role = principal?.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role).Value; modelView.DateLoginFirst = principal?.Claims.FirstOrDefault(c => c.Type == "dateloginfirst").Value; modelView.DateLoginNow = principal?.Claims.FirstOrDefault(c => c.Type == "dateloginnow").Value; modelView.AccessToken = principal?.Claims.FirstOrDefault(c => c.Type == "access_token").Value; modelView.CompanyName = companyName != null?companyName:""; } return(View(modelView)); }
public IActionResult _CompanyNameLayout() { string companyName = _configuration.GetSection("AppSettings").GetSection("CompanyName").Value; ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; LoginModelExtension modelView = new LoginModelExtension(); var user = _IUserService.GetAll().Result.FirstOrDefault(x => x.FYuzaId == HttpContext.User.Identity.Name); var shiiresakien = _ShiiresakiService.GetAllList().Result.FirstOrDefault(x => x.FShiiresakiCd == user.FShiiresakiCd); if (shiiresakien != null) { companyName = shiiresakien.FShiiresakiMei; } TempData["FShiiresakiMei"] = companyName; return(PartialView("_CompanyNameLayout")); }
public IActionResult Index() { ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; LoginModelExtension modelView = new LoginModelExtension(); if (principal != null) { modelView.UserName = HttpContext.User.Identity.Name; modelView.Role = principal?.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role).Value; modelView.DateLoginFirst = principal?.Claims.FirstOrDefault(c => c.Type == "dateloginfirst").Value; modelView.DateLoginNow = principal?.Claims.FirstOrDefault(c => c.Type == "dateloginnow").Value; modelView.AccessToken = principal?.Claims.FirstOrDefault(c => c.Type == "access_token").Value; } return(View(modelView)); }