コード例 #1
0
 public IActionResult Put(string name, [FromBody] SpecifyWinningNumbersCommand winningNumbersCommand)
 {
     try
     {
         _lotteryService.SpecifyWinningNumbers(name, winningNumbersCommand);
         return(new OkResult());
     }
     catch (Exception ex)
     {
         return(new BadRequestObjectResult(ex.Message));
     }
 }
コード例 #2
0
        public void SpecifyWinningNumbers(string name, SpecifyWinningNumbersCommand winningNumbersCommand)
        {
            var existingDraw = _repository.FindByName(name);

            if (existingDraw == null)
            {
                throw new ArgumentException($"Unable to find lottery draw {name}");
            }

            existingDraw.SpecifyWinningNumbers(new Domain.WinningNumbers
            {
                Primary   = winningNumbersCommand.Primary,
                Secondary = winningNumbersCommand.Secondary
            });
            _repository.Update(existingDraw);
        }