public async Task <IActionResult> UpdateSeason(int seasonId, [FromBody] UpdateSeasonBindingModel seasonBindingModel) { var result = await _seasonService.UpdateSeason(seasonId, seasonBindingModel); if (result.ErrorOccurred) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <ResponseDto <BaseModelDto> > UpdateSeason(int seasonId, UpdateSeasonBindingModel seasonBindingModel) { var response = new ResponseDto <BaseModelDto>(); var seasonExists = await _seasonRepository.ExistAsync(x => x.Id == seasonId); if (!seasonExists) { response.AddError(Model.Season, Error.season_NotFound); } var season = await _seasonRepository.GetByAsync(x => x.Id == seasonId); season.SeasonNumber = seasonBindingModel.SeasonNumber; var result = await _seasonRepository.UpdateAsync(season); if (!result) { response.AddError(Model.Season, Error.season_Updating); return(response); } return(response); }