public Response <TeamDTO> AddTeam(TeamDTO teamDTO) { try { TeamRequestValidator validator = new TeamRequestValidator(); ValidationResult results = validator.Validate(teamDTO); if (results.IsValid) { var team = TeamMapper.MapTeamDTOToTeamModel(teamDTO); var teamEntity = _repository.Add(team); _repository.SaveChanges(); var teamEntityDTO = TeamMapper.MapTeamModelToTeamDTO(teamEntity); var response = new Response <TeamDTO> { DTO = teamEntityDTO }; return(response); } else { return(new Response <TeamDTO> { Errors = results.Errors.Select(x => new Error { Type = ErrorType.ValidationError, Message = x.ErrorMessage }).ToList() }); } } catch (Exception ex) { return(new Response <TeamDTO> { Errors = new List <Error>() { new Error { Type = ErrorType.Exception, Message = ex.Message } } }); } }