本文整理汇总了C#中Team.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Team.Init方法的具体用法?C# Team.Init怎么用?C# Team.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team.Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTeam
public Team UpdateTeam(Fixture fixture, Player player)
{
using (var session = NHibernateHelper.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
try
{
var team = session.CreateCriteria(typeof (Team))
.List<Team>().FirstOrDefault(x => x.Fixture.Id.Equals(fixture.Id));
if (team == null)
{
team = new Team();
team.Init();
team.Fixture = fixture;
SetAudit(team);
}
team.AddPlayer(player);
session.SaveOrUpdate(team);
if (fixture.Team == null)
{
fixture.Team = team;
session.SaveOrUpdate(fixture);
}
transaction.Commit();
return team;
}
catch (Exception ex)
{
Logger.Log(LogLevel.Error, ex, string.Empty, null);
transaction.Rollback();
return null;
}
}
}
}
示例2: AddStats
public bool AddStats(List<DLStat> statsList)
{
using (var session = NHibernateHelper.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
try
{
var bwccXmlDoc = new XmlDocument();
bwccXmlDoc.Load(
HttpContext.Current.Server.MapPath(
"~/Modules/ivNet.Club/App_Data/MySql/members.xml"));
var memberType = session.CreateCriteria(typeof (MemberType))
.List<MemberType>().FirstOrDefault(x => x.Name.Equals("Player"));
foreach (var dlStat in statsList)
{
// HowOut
var howout = session.CreateCriteria(typeof (HowOut))
.List<HowOut>().FirstOrDefault(x => x.Name.Equals(dlStat.HowOut)) ??
new HowOut();
if (howout.Id == 0)
{
howout.Name = dlStat.HowOut;
SetAudit(howout);
session.Save(howout);
}
// Fixture
var fixture = session.CreateCriteria(typeof (Fixture))
.List<Fixture>().FirstOrDefault(x => x.FixtureKey.Equals(dlStat.FixtureKey)) ??
new Fixture();
// Player
var player = session.CreateCriteria(typeof (Player))
.List<Player>().FirstOrDefault(x => x.Member.MemberKey.Equals(dlStat.MemberKey)) ??
new Player();
if (player.Id == 0)
{
// Member
var member = session.CreateCriteria(typeof (Member))
.List<Member>().FirstOrDefault(x => x.MemberKey.Equals(dlStat.MemberKey)) ??
new Member();
if (member.Id != 0)
{
member.AddMemberType(memberType);
SetAudit(member);
session.SaveOrUpdate(member);
player = new Player
{
Member = member
};
player.Init();
SetTypeNickname(player, bwccXmlDoc, member.LegacyId);
SetAudit(player);
session.SaveOrUpdate(player);
}
//else
//{
// var cakes = "";
//}
}
//if (fixture.Id == 0)
//{
// var zozo = "";
//}
if (howout.Name != "DNB")
{
var battingStat = new BattingStat
{
Position = dlStat.Position,
Runs = dlStat.RunsScored,
Player = player,
Fixture = fixture,
HowOut = howout
};
SetAudit(battingStat);
session.SaveOrUpdate(battingStat);
}
if (dlStat.OversBowled>0)
{
var bowlingStat = new BowlingStat
{
Overs = dlStat.OversBowled,
Maidens = dlStat.Maidens,
//.........这里部分代码省略.........