コード例 #1
0
        public async Task <IActionResult> PostAsync([FromBody] SaveDispatcherResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var dispatcher = _mapper.Map <SaveDispatcherResource, Dispatcher>(resource);
            // TODO: Implement Response Logic
            var result = await _dispatcherService.SaveAsync(dispatcher);

            if (!result.Sucess)
            {
                return(BadRequest(result.Message));
            }

            var dispatcherResource = _mapper.Map <Dispatcher, DispatcherResource>(result.Resource);

            return(Ok(dispatcherResource));
        }