public IActionResult Put(string name, [FromBody] SpecifyWinningNumbersCommand winningNumbersCommand) { try { _lotteryService.SpecifyWinningNumbers(name, winningNumbersCommand); return(new OkResult()); } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } }
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); }