public EntityActionResult InvitePlayer(Guid playerId, Guid matchId) { EntityActionResult result = new EntityActionResult(); List <string> errors = new List <string>(); if (_playerService.FindBy(p => p.Id == playerId).Any() && _matchService.FindBy(p => p.Id == matchId).Any()) { result = _matchRequestService.Add(new MatchRequest { MatchId = matchId, PlayerId = playerId, MatchRequestStatus = MatchRequestStatus.Pending, }); } else { errors.Add("Player or Match invalid"); } if (!_matchRequestService.Save()) { errors.Add("Something wint wrong saving."); } if (errors.Any()) { result.ErrorCode = 500; result.Success = false; result.Messages = errors; } return(result); }