Ejemplo n.º 1
0
        public async Task <CreateMatchSetResult> Handle(CreateMatchSetCommand command, CancellationToken cancel)
        {
            var set = new MatchSet
            {
                SeasonId       = command.SeasonId,
                MatchSetNumber = _db.MatchSets.Max(ms => ms.MatchSetNumber) + 1
            };

            _db.MatchSets.Add(set);
            await _db.SaveChangesAsync();

            return(new CreateMatchSetResult {
                MatchSet = set
            });
        }
Ejemplo n.º 2
0
        public async Task <CreateSeasonResult> Handle(CreateSeasonCommand message)
        {
            var result = new CreateSeasonResult();

            await ValidateSeason(message, result);

            if (result.Errors.Count < 1)
            {
                result.NewSeason = new Season {
                    Name = message.Name, IsCurrent = true
                };
                _db.Seasons.Add(result.NewSeason);
                await _db.SaveChangesAsync();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <UpdateActiveFlagResult> Handle(UpdateActiveFlagCommand command, CancellationToken cancel)
        {
            var result = new UpdateActiveFlagResult();
            var golfer = await _db.Golfers.FirstOrDefaultAsync(g => g.Id == command.Id);

            if (golfer != null)
            {
                golfer.IsActive = command.Value;
                await _db.SaveChangesAsync();

                result.Golfer = golfer;
            }
            else
            {
                result.Errors.Add($"Could not find golfer with an ID of {command.Id}");
            }
            return(result);
        }