public async Task <IActionResult> Details(Guid id, int?pointsEarned, Guid notificationclicked) { notificationAppService.MarkAsRead(notificationclicked); OperationResultVo <GameViewModel> serviceResult = gameAppService.GetById(CurrentUserId, id); GameViewModel vm = serviceResult.Value; SetGameTeam(vm); SetTranslationPercentage(vm); SetImages(vm); bool isAdmin = false; if (!CurrentUserId.Equals(Guid.Empty)) { ApplicationUser user = await UserManager.FindByIdAsync(CurrentUserId.ToString()); bool userIsAdmin = await UserManager.IsInRoleAsync(user, Roles.Administrator.ToString()); isAdmin = user != null && userIsAdmin; } vm.Permissions.CanEdit = vm.UserId == CurrentUserId || isAdmin; vm.Permissions.CanPostActivity = vm.UserId == CurrentUserId; SetGamificationMessage(pointsEarned); return(View(vm)); }
public async Task <IQueryable <PracticeModel> > GetPractices() { var all = await this.AppRepository.Practices.GetAllAsync(); return(all .Where(x => CurrentUserId.Equals(x.UserId)) .Select(this.TheModelFactory.CreateViewModel) .AsQueryable()); }
public ActivityFormHelper(Activity activity) { Guard.ArgumentNotNull(activity, "activity"); _Activity = activity; UserCalendar uc = UserCalendar.GetCurrentUserCalendar(_Activity.UserId); bool foundUserCalendar = uc != null && uc.AllowAdd.HasValue && uc.AllowEdit.HasValue && uc.AllowDelete.HasValue; //If a user has been granted calendar access to another user, //grant Add/Edit/Delete permissions to everything except Personal Activities. bool viewPersonal = true; if (Activity.Type == ActivityType.atPersonal) { viewPersonal = Activity.UserId == CurrentUserId; } _IsAddAllowed = foundUserCalendar && uc.AllowAdd.Value && viewPersonal; _IsEditAllowed = (foundUserCalendar && uc.AllowEdit.Value && viewPersonal) || CurrentUserId.Equals("ADMIN"); _IsDeleteAllowed = (foundUserCalendar && uc.AllowDelete.Value && viewPersonal) || CurrentUserId.Equals("ADMIN"); _IsCompleteAllowed = (foundUserCalendar && uc.AllowEdit.Value && viewPersonal) || _Activity.MemberOfAdminActivity; }