Exemplo n.º 1
0
        public async Task <ActionResult <ControllerResponse <GetTimerDto> > > create(CreateTimerDto newTimer)
        {
            string userId = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier).ToString();
            var    timer  = _mapper.Map <Timer>(newTimer);

            timer.userId      = userId;
            timer.dateCreated = DateTime.UtcNow;
            await _timerService.createAsync(timer);

            return(Created(new Uri($"{Request.Path}/{timer.id}", UriKind.Relative), new ControllerResponse <GetTimerDto>
            {
                data = _mapper.Map <GetTimerDto>(timer)
            }));
        }