示例#1
0
        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());
        }
示例#2
0
        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"));
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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));
            }
        }
示例#6
0
        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());
        }