Example #1
0
        public IActionResult UpdateGasStation(int id, [FromBody] UpdateGasStationViewModel viewModel)
        {
            GasStation _gasStation = _gasStationService.Get(id);

            if (_gasStation is null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                // Atualizar
                _gasStation.Name         = viewModel.Name;
                _gasStation.CEP          = viewModel.CEP;
                _gasStation.Street       = viewModel.Street;
                _gasStation.Number       = viewModel.Number;
                _gasStation.Neighborhood = viewModel.Neighborhood;
                _gasStation.City         = viewModel.City;
                _gasStation.UF           = viewModel.UF;

                return(Ok(_gasStationService.Update(_gasStation)));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #2
0
        public async Task <IActionResult> Update(long id, [FromBody] UpdateGasStationModel model)
        {
            await gasStationService.Update(id, model);

            return(NoContent());
        }