Ejemplo n.º 1
0
        public async Task <ActionResult <ControllerResponse <GetTimerDto> > > get(string id)
        {
            string userId = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();

            var timer = await _timerService.getByIdAsync(id);

            if (timer == null)
            {
                return(NotFound());
            }
            if (timer.userId != userId)
            {
                throw new UnauthorizedAccessException("Timer don't belong to you");
            }
            return(Ok(new ControllerResponse <GetTimerDto>
            {
                data = _mapper.Map <GetTimerDto>(timer)
            }));
        }