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


C# RepositoryFactory.RegisterUpdate方法代码示例

本文整理汇总了C#中RepositoryFactory.RegisterUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryFactory.RegisterUpdate方法的具体用法?C# RepositoryFactory.RegisterUpdate怎么用?C# RepositoryFactory.RegisterUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RepositoryFactory的用法示例。


在下文中一共展示了RepositoryFactory.RegisterUpdate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddChosenTeam

        public void AddChosenTeam(string gameId, Team chosenTeam)
        {
            var game = GetGame(gameId);
             if (game == null)
             {
            throw new NotFoundException($"Game with ID '{gameId}' not found");
             }

             game.CurrentTeam = chosenTeam;
             using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
             {
            repository.RegisterUpdate(game);
            repository.Save();
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:15,代码来源:GameService.cs

示例2: PlayMatchDay

        public void PlayMatchDay(string seasonId, DateTime matchDay)
        {
            // First check if the given matchDay is the "next" match day
             DateTime nextMatchDay = GetNextMatchDay(seasonId);
             if (!nextMatchDay.Equals(matchDay))
             {
            throw new ConflictException("These matches can't be played now");
             }

             var matchesToPlay = GetBySeasonAndDate(seasonId, matchDay).ToList();
             if (!matchesToPlay.Any())
             {
            throw new NotFoundException("There are no matches on this day");
             }

             foreach (var match in matchesToPlay)
             {
            Play(match);
             }

             using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
             {
            var seasonManager = new SeasonManager(Game);
            var postMatchManager = new PostMatchManager(repository, seasonManager);
            postMatchManager.DoSomething(matchesToPlay);

            // Save the result.
            repository.RegisterUpdate(matchesToPlay);

            repository.Save();
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:32,代码来源:MatchService.cs

示例3: UpdateRating

        //public void Delete(Team team)
        //{
        //   using (var teamRepository = new RepositoryFactory().GetTeamRepository())
        //   {
        //      teamRepository.Delete(team);
        //   }
        //}
        public void UpdateRating(Team team, IEnumerable<Player> squad)
        {
            decimal teamRating = TeamRater.GetRating(squad);
             team.Rating = teamRating;

             using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
             {
            repository.RegisterUpdate(team);
            repository.Save();
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:18,代码来源:TeamService.cs

示例4: CreateGameForUser

        public Game CreateGameForUser(string userId)
        {
            Game game;
             using (var gameRepository = new RepositoryFactory().CreateGameRepository())
             {
            game = gameRepository.Find(x => x.UserId == null).FirstOrDefault();
             }

             if (game != null)
             {
            game.UserId = userId;
            using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
            {
               repository.RegisterUpdate(game);
               repository.Save();
            }
             }

             return game;
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:20,代码来源:GameService.cs

示例5: SubstitutePlayers

        public void SubstitutePlayers(Player player1, Player player2)
        {
            // Update the team order of both players.
             int oldPlayer1TeamOrder = player1.TeamOrder;
             int oldPlayer2TeamOrder = player2.TeamOrder;
             player1.TeamOrder = oldPlayer2TeamOrder;
             player2.TeamOrder = oldPlayer1TeamOrder;

             using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
             {
            repository.RegisterUpdate(player1);
            repository.RegisterUpdate(player2);
            repository.Save();
             }

             var team = player1.Team;
             new TeamService(Game).UpdateRating(team);
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:18,代码来源:PlayerService.cs


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