本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}