public async Task <IActionResult> PutContas(int id, Contas contas) { if (id != contas.Id) { return(BadRequest()); } _context.Entry(contas).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContasExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUsuario(int id, Usuario usuario) { if (id != usuario.id) { return(BadRequest()); } _context.Entry(usuario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEnderecos(int id, Enderecos enderecos) { if (enderecos.Pais != "" && enderecos.Bairro != "" && enderecos.Estado != "" && enderecos.Cidade != "" && enderecos.Cep != "" && enderecos.Numero != 0) { if (id != enderecos.Id) { return(BadRequest()); } _context.Entry(enderecos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnderecosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); } else { return(Content("Devem ser preenchidos todos os campo obrigatórios")); } }
public async Task<ActionResult> Create([Bind(Include = "Codigo,Tipo,Valor,Detalhes,Anunciante,Telefone")] imovel imovel) { if (ModelState.IsValid) { db.Imovel.Add(imovel); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(imovel); }
public async Task <IHttpActionResult> Create([FromBody] Empresa model) { try { if (!ModelState.IsValid) { return(BadRequest("Error al intentar crear el registro")); } conexion.Empresa.Add(model); await conexion.SaveChangesAsync(); return(Ok("Registro creado exitosamente!")); } catch (Exception e) { return(InternalServerError(e)); } }
public async Task <IActionResult> PutFornecedores(int id, Fornecedores fornecedores) { bool verifica = false; if (fornecedores.Cpf != "") { verifica = Verifica_Cpf(fornecedores.Cpf); } else if (fornecedores.Cnpj != "") { verifica = Verifica_Cnpj(fornecedores.Cnpj); } if (id != fornecedores.Id) { return(BadRequest()); } _context.Entry(fornecedores).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FornecedoresExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }