private int EarnedRuns(LogDto logDto) { if (string.IsNullOrEmpty(logDto.ERA)) { return(0); } var outs = Outs(logDto.InningsPitched); var era = Decimal.Parse(logDto.ERA); var erPerOut = era / 27.0M; var er = erPerOut * (decimal)outs; return((int)er); }
private bool EmptyLog(LogDto log) { var isEmpty = false; if (log.InningsPitched == null && log.AtBats.Equals("0") && log.HitByPitch.Equals("0") && log.IntentionalWalks.Equals("0") && log.SacrificeFlys.Equals("0") && log.SacrificeHits.Equals("0") && log.Walks.Equals("0")) { isEmpty = true; } return(isEmpty); }
private void MapLogStats( LogDto logDto, PlayerGameLogViewModel result) { result.IsPitcher = logDto.IsPitcher(); result.IsBatter = logDto.IsBatter(); result.GameStarted = Boolean.Parse(logDto.GameStarted); result.Hits += SetDecimal(logDto.Hits); result.HomeRuns += SetDecimal(logDto.HomeRuns); result.Runs += SetDecimal(logDto.Runs); result.RunsBattedIn += SetDecimal(logDto.RunsBattedIn); result.TotalBases += SetDecimal(logDto.TotalBases); result.Walks += SetDecimal(logDto.Walks); result.StrikeOuts += SetDecimal(logDto.StrikeOuts); result.StolenBases += SetDecimal(logDto.StolenBases); result.CaughtStealing += SetDecimal(logDto.CaughtStealing); result.AtBats += SetInt(logDto.AtBats); result.Era = SetDecimal(logDto.ERA); result.EarnedRuns += EarnedRuns(logDto); result.HitsAllowed += SetInt(logDto.HitsAllowed); result.OutsRecorded += SetInt(logDto.Outs); result.BattersStruckOut += SetInt(logDto.BattersStruckOut); result.WalksAllowed += SetInt(logDto.WalksAllowed); result.InningsPitched += SetDecimal(logDto.InningsPitched); result.Wins += SetInt(logDto.Wins); result.Losses += SetInt(logDto.Losses); result.Saves += SetInt(logDto.Saves); result.QualityStarts += SetInt(logDto.QualityStarts); result.Whip = SetDecimal(logDto.Whip); result.OBP = SetDecimal(logDto.OBP); result.OPS = SetDecimal(logDto.OPS); result.Singles += SetDecimal(logDto.Singles); result.Doubles += SetDecimal(logDto.Doubles); result.Triples += SetDecimal(logDto.Triples); result.IntentionalWalks += SetDecimal(logDto.IntentionalWalks); result.HitByPitch += SetDecimal(logDto.HitByPitch); result.Sacrifices += SetDecimal(logDto.SacrificeFlys) + SetDecimal(logDto.SacrificeHits); }