示例#1
0
 public IActionResult Index()
 {
     if (!string.IsNullOrEmpty(User.Identity.Name))
     {
         var user     = UserRepository.GetUserByUsername(User.Identity.Name);
         var userRole = UserRoleRepository.GetAllUserRolesByUserID(user.ID).FirstOrDefault();
         var role     = RoleRepository.GetRoleByID(userRole.RoleID);
         ViewBag.IsAdmin = new Utility().IsUserHasAdminRole(role.RoleCode);
     }
     else
     {
         ViewBag.IsAdmin = false;
     }
     return(View(BlogRepository.GetAllBlogs().ToList()));
 }