Beispiel #1
0
        public async Task <TaskRole> AddAsync(TaskRolePostDto entity)
        {
            TaskRolePostDtoValidator validator = new TaskRolePostDtoValidator();
            ValidationResult         results   = validator.Validate(entity);

            if (!results.IsValid)
            {
                throw new ValidationException("TaskRolePostDTO", string.Join(". ", results.Errors));
            }

            return(await _repository.AddAsync(mapper.Map <TaskRole>(entity)));
        }
        public async Task <IActionResult> AddNewTaskRole([FromBody] TaskRolePostDto taskRolePostDto)
        {
            var taskRoleResp = await taskRoleService.AddAsync(taskRolePostDto);

            return(CreatedAtAction("GetClient", new { id = taskRoleResp.ID }, mapper.Map <TaskRoleResponseDto>(taskRoleResp)));
        }