public async Task <IActionResult> Edit(int id, [Bind("Id,Marca,Modelo,versao, Observacao, Ano, Quilometragem")] AnuncioWebmotors anuncioWebmotors) { if (id != anuncioWebmotors.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(anuncioWebmotors); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnuncioWebmotorsExists(anuncioWebmotors.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(anuncioWebmotors)); }
public async Task <ActionResult <AnuncioWebmotors> > PostAnuncioWebmotors(AnuncioWebmotors anuncioWebmotors) { _context.AnuncioWebmotors.Add(anuncioWebmotors); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAnuncioWebmotors", new { id = anuncioWebmotors.ID }, anuncioWebmotors)); }
public async Task <IActionResult> PutAnuncioWebmotors(int id, AnuncioWebmotors anuncioWebmotors) { if (id != anuncioWebmotors.ID) { return(BadRequest()); } _context.Entry(anuncioWebmotors).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnuncioWebmotorsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: Anuncio/Delete/5 public ActionResult Delete(int id) { AnuncioWebmotors anuncio = new AnuncioWebmotors(); anuncio = anuncioRepo.GetAnuncioById(id); return(View(anuncio)); }
public AnuncioWebmotors GetAnuncioById(int id) { AnuncioWebmotors anuncio = new AnuncioWebmotors(); var query = "Select * from tb_AnuncioWebmotors Where Id = @Id"; anuncio = db.Query <AnuncioWebmotors>(query, new { @id = id }).FirstOrDefault(); return(anuncio); }
public async Task <IActionResult> Create([Bind("Id,Marca,Modelo,versao, Observacao, Ano, Quilometragem")] AnuncioWebmotors anuncioWebmotors) { if (ModelState.IsValid) { _context.Add(anuncioWebmotors); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(anuncioWebmotors)); }
public async Task <IActionResult> PostAnuncioWebmotors([FromBody] AnuncioWebmotors anuncioWebmotors) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Anuncios.Add(anuncioWebmotors); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAnuncioWebmotors", new { id = anuncioWebmotors.Id }, anuncioWebmotors)); }
private async Task <AnuncioWebmotorsViewModel> CarregarInformacoes(AnuncioWebmotors model) { var makes = await _anuncioWebmotorsService.GetMakes(); return(new AnuncioWebmotorsViewModel() { ID = model.ID, Ano = model.Ano, Marca = model.Marca ?? string.Empty, Modelo = model.Modelo ?? string.Empty, Versao = model.Versao ?? string.Empty, Quilometragem = model.Quilometragem, Observacao = model.Observacao, Marcas = makes.Select(x => x.Name), Modelos = new List <string>(), Versoes = new List <string>() }); }
public ActionResult Edit(AnuncioWebmotors anuncio, FormCollection collection) { if (ModelState.IsValid) { try { // TODO: Add update logic here anuncioRepo.UpdateAnuncio(anuncio); return(RedirectToAction("Index")); } catch { return(View()); } } anuncio.Marca = String.Empty; anuncio.Modelo = String.Empty; anuncio.Versao = String.Empty; return(View(anuncio)); }
public ActionResult Create(AnuncioWebmotors anuncio) { if (ModelState.IsValid) { try { // TODO: Add insert logic here anuncioRepo.AddAnuncio(anuncio); return(RedirectToAction("Index")); } catch { return(View()); } } anuncio.Marca = String.Empty; anuncio.Modelo = String.Empty; anuncio.Versao = String.Empty; return(View(anuncio)); }
public void Remove(AnuncioWebmotors obj) { throw new NotImplementedException(); }
public void Update(AnuncioWebmotors obj) => _repository.Update(obj);
public Task AddAsync(AnuncioWebmotors obj) => _repository.AddAsync(obj);
public void UpdateAnuncio(AnuncioWebmotors anuncio) { var query = "Update tb_AnuncioWebmotors set Marca = @Marca,Modelo = @Modelo,Versao = @Versao,Ano = @Ano,Quilometragem = @Quilometragem,Observacao = @Observacao Where Id = @Id"; int rowsAffected = db.Execute(query, anuncio); }
public void AddAnuncio(AnuncioWebmotors anuncio) { var query = "Insert into tb_AnuncioWebmotors (Marca,Modelo,Versao,Ano,Quilometragem,Observacao) values (@Marca,@Modelo,@Versao,@Ano,@Quilometragem,@Observacao)"; int rowsAffected = db.Execute(query, anuncio); }
public async Task <bool> AtualizarAnuncio(AnuncioWebmotors anuncio) { _repository.Update(anuncio); return(await _repository.SaveChangesAsync()); }
public async Task <bool> DeletarAnuncio(AnuncioWebmotors anuncio) { _repository.Delete(anuncio); return(await _repository.SaveChangesAsync()); }