Пример #1
0
        public async Task <IActionResult> AddHealthAsync(string userId, HealthAddViewModel model)
        {
            if (userId != User.FindFirst(ClaimTypes.NameIdentifier).Value || User.FindFirst(ClaimTypes.Role).Value == EnumRoles.ORGANIZER)
            {
                return(Unauthorized());
            }

            var healthDto = _mapper.Map <HealthDto>(model);

            healthDto = await _healthRepository.AddHealthAsync(userId, healthDto);

            if (healthDto != null)
            {
                return(CreatedAtRoute("GetHealthUser", new { userId = userId }, healthDto));
            }

            return(BadRequest());
        }