public CriarAnuncioResponse CriarAnuncio(CriarAnuncioRequest criarAnuncioRequest) { Anuncio anuncio = new Anuncio(); anuncio = criarAnuncioRequest.Anuncio; CriarAnuncioResponse criarAnuncioResponse = new CriarAnuncioResponse(); criarAnuncioResponse.Successo = _servicoAnuncio.Cadastrar(anuncio); return(criarAnuncioResponse); }
public IActionResult Edit(CriarAnuncioRequest criarAnuncioRequest) { if (ModelState.IsValid) { CriarAnuncioResponse response = _applicationTesteWebMotorsService.CriarAnuncio(criarAnuncioRequest); return(RedirectToAction("Index")); } else { return(View(criarAnuncioRequest.Anuncio)); } }
public async Task <CriarAnuncioModelResponse> Criar(CriarAnuncioModel anuncio) { AdvertModel entradaAPI = _mapper.Map <AdvertModel>(anuncio); string jsonEntrada = JsonSerializer.Serialize(entradaAPI); HttpResponseMessage resposta = await _client.PostAsync($"{_client.BaseAddress}/criar", new StringContent(jsonEntrada)).ConfigureAwait(false); string jsonSaidaAPI = await resposta.Content.ReadAsStringAsync(); CriarAnuncioResponse saidaAPI = JsonSerializer.Deserialize <CriarAnuncioResponse>(jsonSaidaAPI); CriarAnuncioModelResponse retorno = _mapper.Map <CriarAnuncioModelResponse>(saidaAPI); return(retorno); }
public IActionResult Criar(AnuncioView anuncioView) { CriarAnuncioRequest criarAnuncioRequest = new CriarAnuncioRequest(); criarAnuncioRequest.Anuncio = new Anuncio() { Ano = anuncioView.Ano, Id = anuncioView.Id, Marca = anuncioView.Marca, Modelo = anuncioView.Modelo, Observacao = anuncioView.Observacao, Quilometragem = anuncioView.Quilometragem, Versao = anuncioView.Versao }; CriarAnuncioResponse response = _applicationTesteWebMotorsService.CriarAnuncio(criarAnuncioRequest); AnuncioView accView = response.AnuncioView; return(RedirectToAction("Index")); }