Exemplo n.º 1
0
        public async Task <IActionResult> AddMeetAsync(
            [FromBody] MeetForm meetForm,
            CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(ModelState)));
            }

            var meetId = await _meetService.CreateMeetAsync(
                meetForm.MeetName,
                meetForm.MeetDate,
                meetForm.MeetLocation,
                meetForm.MeasurementType,
                ct);

            return(Created(
                       Url.Link(nameof(MeetsController.GetMeetByIdAsync),
                                new { meetId }),
                       null));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditMeetAsync(
            int meetId,
            [FromBody] MeetForm meetForm,
            CancellationToken ct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiError(ModelState)));
            }

            var(succeeded, error) = await _meetService.EditMeetAsync(
                meetId,
                meetForm.MeetName,
                meetForm.MeetDate,
                meetForm.MeetLocation,
                meetForm.MeasurementType,
                ct);

            if (succeeded)
            {
                return(Ok());
            }
            return(NotFound(error));
        }