Example #1
0
        private async Task CheckForAccessToSheriffByLocation <T>(int id) where T : SheriffEvent
        {
            var sheriffEvent = await SheriffService.GetSheriffEvent <T>(id);

            if (sheriffEvent == null)
            {
                throw new NotFoundException(CouldNotFindSheriffEventError);
            }
            var savedSheriff = await SheriffService.GetSheriff(sheriffEvent.SheriffId, null);

            if (savedSheriff == null)
            {
                throw new NotFoundException(CouldNotFindSheriffError);
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, savedSheriff.HomeLocationId))
            {
                throw new NotAuthorizedException();
            }
        }