public static async Task<ContentResult> Add(SocialGamificationAssetContext db, Match match, Actor actor) { // Add actors to this match var matchActor = new MatchActor { MatchId = match.Id, ActorId = actor.Id }; db.MatchActors.Add(matchActor); try { await db.SaveChangesAsync(); } catch (DbEntityValidationException e) { return HttpResponseHelper.ErrorContentResult(e.Message, StatusCodes.Status500InternalServerError); } for (var i = 1; i <= match.TotalRounds; ++i) { // Add round(s) entry for each Actor var matchRound = new MatchRound { MatchActorId = matchActor.Id, RoundNumber = i }; db.MatchRounds.Add(matchRound); try { await db.SaveChangesAsync(); } catch (DbEntityValidationException e) { return HttpResponseHelper.ErrorContentResult(e.Message, StatusCodes.Status500InternalServerError); } } return null; }
public static async Task <ContentResult> Add(SocialGamificationAssetContext db, Match match, Actor actor) { // Add actors to this match var matchActor = new MatchActor { MatchId = match.Id, ActorId = actor.Id }; db.MatchActors.Add(matchActor); try { await db.SaveChangesAsync(); } catch (DbEntityValidationException e) { return(HttpResponseHelper.ErrorContentResult(e.Message, StatusCodes.Status500InternalServerError)); } for (var i = 1; i <= match.TotalRounds; ++i) { // Add round(s) entry for each Actor var matchRound = new MatchRound { MatchActorId = matchActor.Id, RoundNumber = i }; db.MatchRounds.Add(matchRound); try { await db.SaveChangesAsync(); } catch (DbEntityValidationException e) { return(HttpResponseHelper.ErrorContentResult(e.Message, StatusCodes.Status500InternalServerError)); } } return(null); }