private static Result MapResult(GameResultEntity gr) { return(new Result { SetScores = new List <Score> { new Score { Home = gr.HomeSet1Score, Away = gr.AwaySet1Score, IsTechnicalDefeat = gr.IsSet1TechnicalDefeat }, new Score { Home = gr.HomeSet2Score, Away = gr.AwaySet2Score, IsTechnicalDefeat = gr.IsSet2TechnicalDefeat }, new Score { Home = gr.HomeSet3Score, Away = gr.AwaySet3Score, IsTechnicalDefeat = gr.IsSet3TechnicalDefeat }, new Score { Home = gr.HomeSet4Score, Away = gr.AwaySet4Score, IsTechnicalDefeat = gr.IsSet4TechnicalDefeat }, new Score { Home = gr.HomeSet5Score, Away = gr.AwaySet5Score, IsTechnicalDefeat = gr.IsSet5TechnicalDefeat } }, GameScore = new Score { Home = gr.HomeSetsScore, Away = gr.AwaySetsScore, IsTechnicalDefeat = gr.IsTechnicalDefeat }, Penalty = MapPenalty(gr) }); }
/// <summary> /// Adds new game. /// </summary> /// <param name="newEntity">Game to add.</param> public void Add(Game newEntity) { var newGame = new GameResultEntity(); DomainToDal.Map(newGame, newEntity); _dalGame.Add(newGame); _unitOfWork.Commit(); newEntity.Id = newGame.Id; }
private GameResultDto Map(GameResultEntity gr, string divisionName, int divisionId, int groupId) { var result = GetGameResultDtoMap()(gr); result.DivisionName = divisionName; result.DivisionId = divisionId; result.GroupId = groupId; return(result); }
private static Penalty MapPenalty(GameResultEntity gr) { Penalty result; result = gr.PenaltyTeam != 0 ? new Penalty { IsHomeTeam = gr.PenaltyTeam == 1, Amount = gr.PenaltyAmount, Description = gr.PenaltyDescription } : null; return(result); }
/// <summary> /// Removes game by its identifier. /// </summary> /// <param name="id">Identifier of the game.</param> public void Remove(int id) { GameResultEntity dalToRemove; if (_dalGame.Local.Any(gr => gr.Id == id)) { dalToRemove = _dalGame.Find(id); } else { dalToRemove = new GameResultEntity { Id = id }; _dalGame.Attach(dalToRemove); } _dalGame.Remove(dalToRemove); }
/// <summary> /// Maps DAL model of game to domain model of game result. /// </summary> /// <param name="to">DAL model of game result.</param> /// <param name="from">Domain model of game.</param> public static void Map(GameResultEntity to, Game from) { to.Id = from.Id; to.TournamentId = from.TournamentId; to.HomeTeamId = from.HomeTeamId; to.AwayTeamId = from.AwayTeamId; to.StartTime = from.GameDate; to.RoundNumber = from.Round; to.GameNumber = from.GameNumber; if (from.Result != null) { to.HomeSetsScore = from.Result.GameScore.Home; to.AwaySetsScore = from.Result.GameScore.Away; to.IsTechnicalDefeat = from.Result.GameScore.IsTechnicalDefeat; to.HomeSet1Score = from.Result.SetScores[0].Home; to.AwaySet1Score = from.Result.SetScores[0].Away; to.IsSet1TechnicalDefeat = from.Result.SetScores[0].IsTechnicalDefeat; to.HomeSet2Score = from.Result.SetScores[1].Home; to.AwaySet2Score = from.Result.SetScores[1].Away; to.IsSet2TechnicalDefeat = from.Result.SetScores[1].IsTechnicalDefeat; to.HomeSet3Score = from.Result.SetScores[2].Home; to.AwaySet3Score = from.Result.SetScores[2].Away; to.IsSet3TechnicalDefeat = from.Result.SetScores[2].IsTechnicalDefeat; to.HomeSet4Score = from.Result.SetScores[3].Home; to.AwaySet4Score = from.Result.SetScores[3].Away; to.IsSet4TechnicalDefeat = from.Result.SetScores[3].IsTechnicalDefeat; to.HomeSet5Score = from.Result.SetScores[4].Home; to.AwaySet5Score = from.Result.SetScores[4].Away; to.IsSet5TechnicalDefeat = from.Result.SetScores[4].IsTechnicalDefeat; if (from.Result.Penalty != null) { to.PenaltyTeam = (byte)(from.Result.Penalty.IsHomeTeam ? 1 : 2); to.PenaltyAmount = from.Result.Penalty.Amount; to.PenaltyDescription = from.Result.Penalty.Description; } else { to.PenaltyTeam = 0; to.PenaltyAmount = 0; } } to.UrlToGameVideo = from.UrlToGameVideo; }
private static Penalty MapPenalty(GameResultEntity gr) { Penalty result; if (gr.PenaltyTeam != 0) { result = new Penalty { IsHomeTeam = gr.PenaltyTeam == 1, Amount = gr.PenaltyAmount, Description = gr.PenaltyDescription }; } else { result = null; } return(result); }