コード例 #1
0
        public async Task <IActionResult> AddOrUpdateEnglishBarHeightsAsync(
            [FromBody] BarHeightsForm <EnglishBarHeight> barHeightsForm,
            CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(ModelState)));
            }

            var evt = await _eventService.GetEventByIdAsync(barHeightsForm.eventId, ct);

            if (evt.Params.EventType[0] != 'V')
            {
                return(BadRequest("Event type not vertical"));
            }
            if (evt.Params.MeasurementType[0] != 'E')
            {
                return(BadRequest("Measurement type not English"));
            }

            await _eventService.AddOrUpdateEnglishBarHeightsAsync(
                barHeightsForm, ct);

            return(Created(Url.Link(nameof(EventsController.GetEventByIdAsync),
                                    new { barHeightsForm.eventId }),
                           null));
        }