예제 #1
0
        public async Task <IActionResult> Put([FromRoute] Guid id, [FromBody] TeamMutateModel teamMutate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Team team = await this.teamsRepository.GetOne(id);

            if (team == null || id != team.Id)
            {
                return(BadRequest());
            }

            if (!string.IsNullOrEmpty(teamMutate.Name))
            {
                team.Name = teamMutate.Name;
            }

            if (teamMutate.Description != null)
            {
                team.Description = teamMutate.Description;
            }

            team.UpdatedAt = teamMutate.UpdatedAt;

            try
            {
                await teamsRepository.UpdateAsync(team);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await teamsRepository.EntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }