コード例 #1
0
        public async Task <ActionResult <Squad> > UpdateSquad(int Id, SquadUpdateDto squadUpdateDto)
        {
            try
            {
                var squadToUpdate = await _squadRepository.GetSquadAsync(Id);

                if (squadToUpdate == null)
                {
                    return(NotFound($"User with Id={Id} not found"));
                }

                _mapper.Map(squadUpdateDto, squadToUpdate);
                await _squadRepository.UpdateSquadAsync(squadToUpdate);

                return(NoContent());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Erorr updating data"));
            }
        }