private void FulFillList(UserViewModel user) { Expression <Func <ProfileViewModel, bool> > filterProfile = (ProfileViewModel p) => (p.Active.Equals(activeStatus)); var Profiles = _profileAppService.Get(filterProfile, orderBy: q => q.OrderBy(d => d.Name)); user.ProfileList = new List <ProfileViewModel>(Profiles); }
public async Task <IActionResult> Details(Guid id, string userHandler) { ProfileViewModel vm = await profileAppService.Get(CurrentUserId, id, userHandler, ProfileType.Personal); if (vm == null) { ProfileViewModel profile = profileAppService.GenerateNewOne(ProfileType.Personal); ApplicationUser user = await UserManager.FindByIdAsync(id.ToString()); if (user != null) { profile.UserId = id; profileAppService.Save(CurrentUserId, profile); } else { TempData["Message"] = SharedLocalizer["User not found!"].Value; return(RedirectToAction("Index", "Home")); } vm = profile; } gamificationAppService.FillProfileGamificationDetails(CurrentUserId, ref vm); if (CurrentUserId != Guid.Empty) { ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString()); bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString()); vm.Permissions.IsAdmin = userIsAdmin; vm.Permissions.CanEdit = vm.UserId == CurrentUserId; vm.Permissions.CanFollow = vm.UserId != CurrentUserId; vm.Permissions.CanConnect = vm.UserId != CurrentUserId; } ViewData["ConnecionTypes"] = EnumExtensions.ToJson(UserConnectionType.Mentor); return(View(vm)); }
// [ClaimsAuthorize(claimType: TypePermissionEnum.PROFILE, claimValue: ValuePermissionEnum.CONSULT)] public ActionResult Index(string ResearchName, string ResearchActive) { var name = (ResearchName == null || ResearchName.Trim().Equals("")) ? null : ResearchName.Trim(); var active = (ResearchActive == null || ResearchActive.Trim().Equals("")) ? null : ResearchActive.Trim(); ProfileViewIndex Profiles = new ProfileViewIndex(); if (name == null && active == null) { Profiles.ProfileList = new List <ProfileViewModel>(_profileAppService.GetAll()); } else { Expression <Func <ProfileViewModel, bool> > filter = null; filter = (ProfileViewModel p) => ((name != null) ? p.Name.ToUpper().Contains(name.ToUpper()) : true) && ((active != null) ? p.Active.Equals(active) : true); Profiles.ProfileList = new List <ProfileViewModel>(_profileAppService.Get(filter, orderBy: q => q.OrderBy(d => d.Name))); Profiles.ResearchName = ResearchName; } return(View(Profiles)); }