public BattingStat SaveBattingStat(Player player, Fixture fixture, HowOut howOut, int position, int runs, decimal overs) { if (howOut.Name == "DNB") return null; using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { try { var stat = session.CreateCriteria(typeof(BattingStat)) .List<BattingStat>() .FirstOrDefault(x => x.Player.Id.Equals(player.Id) && x.Fixture.Id.Equals(fixture.Id)) ?? new BattingStat (); if (stat.Id == 0) { stat.Fixture = fixture; stat.Player = player; } stat.HowOut = howOut; stat.Overs = overs; stat.Position = position; stat.Runs = runs; SetAudit(stat); session.SaveOrUpdate(stat); transaction.Commit(); return stat; } catch (Exception ex) { Logger.Log(LogLevel.Error, ex, string.Empty, null); transaction.Rollback(); return null; } } } }
public ConfigItem SaveHowOut(ConfigItem newItem, out HowOut howOut) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { try { var item = session.CreateCriteria(typeof(HowOut)) .List<HowOut>() .FirstOrDefault(x => x.Name.ToLowerInvariant() == newItem.Name.ToLowerInvariant()) ?? new HowOut { Name = newItem.Name }; if (item.Id != 0) { transaction.Rollback(); howOut = item; return null; } SetAudit(item); session.SaveOrUpdate(item); transaction.Commit(); howOut = item; newItem.Id = item.Id; } catch (Exception ex) { howOut = null; Logger.Log(LogLevel.Error, ex, string.Empty, null); transaction.Rollback(); } return newItem; } } }
public void RecordDelivery(int runs, HowOut howOut, IPlayer assistedBy) { if (Ended) { return; } RecordDelivery(runs, howOut); }
public void RecordDelivery(int runs, HowOut howOut) { if (Ended) { return; } _wicketsRemaining--; IPlayer nonStriker = _currentPartnership.Striker; RecordDelivery(runs); }