Exemple #1
0
        public async Task <ActionResult> EnterDoorAsync(int officeId, int doorId)
        {
            var door = await GetAndEnsureDoorAsync(officeId, doorId);

            var accessResult = await _authorizationService.AuthorizeAsync(
                User,
                null,
                new DoorAuthorizationRequirement
            {
                DoorId = doorId
            }
                );

            if (!accessResult.Succeeded)
            {
                throw ApiException.Forbidden("Access denied");
            }

            var entranceLog = _mapper.MultipleMap <EntranceLogEntry>(door, User);
            await _entranceLogRepository.AddLogAsync(entranceLog);

            return(Ok());
        }