Example #1
0
        public async Task <IActionResult> CreateTeamAsync([FromBody] TeamModel team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ResultData <Team> result = await _teamService.CreateTeamAsync(team.Name, team.OwnerId);

            if (!result.Success)
            {
                return(BadRequest(new { message = result.Message }));
            }

            TeamModel viewModel = new TeamModel
            {
                Id           = result.Data.Id,
                Name         = result.Data.Name,
                CreationDate = result.Data.CreationDate,
                OwnerId      = result.Data.OwnerId,
            };

            return(Ok(viewModel));
        }