Ejemplo n.º 1
0
        public async Task <ActionResult <ColetorViewModel> > Post(ColetorViewModel coletorViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            coletorViewModel.Id = await _coletorService.Create(_mapper.Map <Coletor>(coletorViewModel));

            return(CustomResponse(coletorViewModel));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <ColetorViewModel> > Put(long id, [FromBody] ColetorViewModel coletorViewModel)
        {
            if (id != coletorViewModel.Id)
            {
                return(BadRequest());
            }

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

            await _coletorService.Update(_mapper.Map <Coletor>(coletorViewModel));

            return(CustomResponse(coletorViewModel));
        }