public async Task <IHttpActionResult> Update(int id, [FromBody] AddUpdateMatchModel matchModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var match = await _matchesRepo.GetMatchByIdAsync(id); if (match != null) { //TODO: Following line not working -- AutoMapper //AddUpdateMatchDto aumDto = Mapper.Map<AddUpdateMatchModel, AddUpdateMatchDto>(matchModel); AddUpdateMatchDto aumDto = new AddUpdateMatchDto() { LocationTitle = matchModel.LocationTitle, LocationMapUrl = matchModel.LocationMapUrl, MatchDate = matchModel.MatchDate, PlayerLimit = matchModel.PlayerLimit }; if (await _matchesRepo.UpdateMatchAsync(match, aumDto) <= 0) { return(InternalServerError()); } } else { return(NotFound()); } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <int> UpdateMatchAsync(Match match, AddUpdateMatchDto aumDto) { match.MatchDate = aumDto.MatchDate; match.LocationMapUrl = aumDto.LocationMapUrl; match.LocationTitle = aumDto.LocationTitle; match.PlayerLimit = aumDto.PlayerLimit; return(await _context.SaveChangesAsync()); }