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


C# RepositoryFactory.Save方法代码示例

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


在下文中一共展示了RepositoryFactory.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Can_Save_New_Customer_With_Orders_And_Details

        public void Can_Save_New_Customer_With_Orders_And_Details()
        {
            var customer = GetCustomer();

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
                Assert.IsNotNull(cust);
                CollectionAssert.IsNotEmpty(cust.Orders);
                Assert.IsNotNull(cust.Orders.First(o => o.OrderDetail != null).OrderDetail);
            }
        }
开发者ID:Mir4ik,项目名称:TestRepo,代码行数:18,代码来源:EntiyFrameworkTests.cs

示例3: Can_Save_New_Customer

        public void Can_Save_New_Customer()
        {
            var customer = new Customer
            {
                ContactName = "johnny",
                Email = "[email protected]"
            };

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
                Assert.IsNotNull(cust);
            }
        }
开发者ID:Mir4ik,项目名称:TestRepo,代码行数:20,代码来源:EntiyFrameworkTests.cs

示例4: 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

示例5: 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

示例6: CreateGame

        public Game CreateGame()
        {
            using (var log = Logger.GetLogger(this))
             {
            using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
            {
               // Insert the game into the database.
               string gameName = DateTime.Now.ToString("yyyyMMddHHmmss");
               var game = new Game { Name = gameName };

               // Create teams and players.
               var teamsAndPlayers = CreateTeamsAndPlayers(game);

               // Insert teams.
               repository.RegisterInsert(teamsAndPlayers.Teams);

               // Insert players and skill scores.
               repository.RegisterInsert(teamsAndPlayers.Players);
               foreach (var player in teamsAndPlayers.Players)
               {
                  repository.RegisterInsert(player.SkillScores);
               }

               var seasonManager = new SeasonManager(game);

               // Create a season with match schedules.
               var season = seasonManager.CreateFirstSeason(game, teamsAndPlayers.Teams, repository);

               // Insert the season statistics and season/team statistics.
               var seasonStatistics = new SeasonStatistics(season);
               repository.RegisterInsert(seasonStatistics);
               foreach (var team in teamsAndPlayers.Teams)
               {
                  var seasonTeamStatistics = new SeasonTeamStatistics(season, team);
                  repository.RegisterInsert(seasonTeamStatistics);
               }

               // Assign the user a random team.
               //TODO let the user choose a team via the GUI...
               //var teamToManage = _listRandomizer.GetItem(teamsAndPlayers.Teams);
               //game.CurrentTeam = teamToManage;

               repository.RegisterInsert(game);

               repository.Save();

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

示例7: DeleteGame

        public void DeleteGame(Game game)
        {
            using (Logger.GetLogger(this, game))
             {
            var playerService = ServiceFactory.CreatePlayerService(game);
            var teamService = ServiceFactory.CreateTeamService(game);
            var seasonManager = new SeasonManager(game);

            using (var repository = new RepositoryFactory().CreateUnitOfWorkRepository())
            {
               // Delete all players.
               var players = playerService.GetAll(game);
               repository.RegisterDelete(players);

               // Delete all teams.
               var teams = teamService.GetAll(game);
               repository.RegisterDelete(teams);

               // Delete the seasons, matches etc.
               seasonManager.DeleteSeasons(repository);

               // Delete the game itself.
               repository.RegisterDelete(game);

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

示例8: 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

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