Beispiel #1
0
        public async Task <ActionResult <CorridaViewModel> > Adicionar(CorridaViewModel corridaViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            var model = _mapper.Map <Corrida>(corridaViewModel);
            await _corridaService.Adicionar(model);

            return(CustomResponse(_mapper.Map <CorridaViewModel>(model)));
        }
Beispiel #2
0
        public async Task <ActionResult <CorridaViewModel> > Atualizar(int id, CorridaViewModel corridaViewModel)
        {
            if (id != corridaViewModel.Id)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            await _corridaService.Atualizar(_mapper.Map <Corrida>(corridaViewModel));

            return(CustomResponse(corridaViewModel));
        }