public ActionResult UpdateDoubleLeagueMatch(int matchId, JsonPatchDocument <DoubleLeagueMatchUpdateDto> patchDoc) { try { string userId = User.Identity.Name; string currentOrganisationId = User.FindFirst("CurrentOrganisationId").Value; var match = _doubleLeaugeMatchService.GetDoubleLeagueMatchByIdSimple(matchId); if (match == null) { return(NotFound()); } bool hasPermission = _doubleLeaugeMatchService.CheckMatchAccess(matchId, int.Parse(userId), int.Parse(currentOrganisationId)); if (!hasPermission) { return(Forbid()); } var matchToPatch = _mapper.Map <DoubleLeagueMatchUpdateDto>(match); patchDoc.ApplyTo(matchToPatch, ModelState); if (!TryValidateModel(matchToPatch)) { return(ValidationProblem(ModelState)); } _mapper.Map(matchToPatch, match); _doubleLeaugeMatchService.UpdateDoubleLeagueMatch(match); _doubleLeaugeMatchService.SaveChanges(); return(NoContent()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }