public async Task <IActionResult> Put(
            [HttpTrigger(AuthorizationLevel.Function, "put", Route = "entry/{id}")] HttpRequest req,
            ILogger log, string id)
        {
            EntryDTO data = await GetEntryData(req);

            if (data == null)
            {
                return(new BadRequestObjectResult("Must provide Entry details in POST body."));
            }

            var competitionId = CompetitionId.With(data.CompetitionId);
            var entryId       = EntryId.With(id);

            CorrectEntryTimeCommand correctEntryTimeCommand = new CorrectEntryTimeCommand(competitionId, entryId, data.TimeInMillis);
            var result = await _eventFlow.PublishAsync(correctEntryTimeCommand, CancellationToken.None);

            return(result?.IsSuccess == true
                ? (ActionResult) new OkObjectResult($"{JsonConvert.SerializeObject(correctEntryTimeCommand)}")
                : new BadRequestObjectResult($"Cannot or did not update entry {id}"));
        }
        public async Task <IActionResult> Post(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "entry")] HttpRequest req,
            ILogger log)
        {
            EntryDTO data = await GetEntryData(req);

            if (data == null)
            {
                return(new BadRequestObjectResult("Must provide Entry details in POST body."));
            }

            var competitionId = CompetitionId.With(data.CompetitionId);
            var entryId       = EntryId.New;

            RecordEntryCommand recordEntryCommand = new RecordEntryCommand(competitionId, entryId, data.Discipline, data.Name, data.TimeInMillis);
            var result = await _eventFlow.PublishAsync(recordEntryCommand, CancellationToken.None);

            return(result?.IsSuccess == true
                ? (ActionResult) new OkObjectResult($"{recordEntryCommand.EntryId}")
                : new BadRequestObjectResult("Cannot create new entry"));
        }