当前位置: 首页>>代码示例>>C#>>正文


C# Team.Init方法代码示例

本文整理汇总了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;
                    }
                }
            }
        }
开发者ID:ivNetAdmin,项目名称:ivNet.Club.v.1.9.1,代码行数:42,代码来源:StatsServices.cs

示例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,
//.........这里部分代码省略.........
开发者ID:ivNetAdmin,项目名称:ivNet.Club.v.1.9.1,代码行数:101,代码来源:DataLoadServices.cs


注:本文中的Team.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。