public async Task <IActionResult> AdminUsersAsync(int?pageNumber) { //EF core var CurrentUserId = _userManager.GetUserId(User as ClaimsPrincipal); ArtGalleryContext context = new ArtGalleryContext(); IQueryable <UserViewModel> UsersData = (IQueryable <UserViewModel>)(from U in context.Account where U.IsUser == true select new UserViewModel { UserName = U.UserName, IsActive = U.IsActive, }); AdminUsersViewModel AdminUsersVM = new AdminUsersViewModel(); AdminUsersVM.UserPaginatedList = await PaginatedList <UserViewModel> .CreateAsunc((IQueryable <UserViewModel>) UsersData, pageNumber ?? 1, 4); AdminUsersVM.FullName = context.Account.Where(A => A.Id == CurrentUserId).Select(A => A.FirstName).FirstOrDefault(); AdminUsersVM.ProfilePicture = context.ProfileImage.Where(PI => PI.AccountId == CurrentUserId).Select(PI => PI.ImageName).FirstOrDefault(); return(View(AdminUsersVM)); }
public async Task <IActionResult> AdminCompetition(int?pageNumber) { ArtGalleryContext context = new ArtGalleryContext(); AdminCompetitionViewModel CVM = new AdminCompetitionViewModel(); IQueryable <CompetitionViewModel> CompetitionList = (from C in context.Competition select new CompetitionViewModel { CompetitionName = C.Title, //ImageName = C.CompetitionImage.ImageName, StartDate = C.StartDate, Category = C.Category.Name, SubCategory = C.SubCategory.Name, }); CVM.CompetitionList = await PaginatedList <CompetitionViewModel> .CreateAsunc(CompetitionList, pageNumber ?? 1, 4); var CurrentUserId = _userManager.GetUserId(User as ClaimsPrincipal); var AccountFirstName = context.Account.Where(A => A.Id == CurrentUserId).Select(A => A.FirstName).FirstOrDefault(); var ProfileImageName = context.ProfileImage.Where(PI => PI.AccountId == CurrentUserId).Select(PI => PI.ImageName).FirstOrDefault(); CVM.FullName = AccountFirstName; CVM.ProfilePicture = ProfileImageName; return(View(CVM)); }