public async Task <IActionResult> Edit(int id, [Bind("Id,RazaoSocial,NomeFantasia,Cnpj,Endereço,Numero,Complemento,Bairro,Cidade,Estado,Contato,Telefone,Email")] Fornecedor fornecedor)
        {
            if (id != fornecedor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fornecedor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FornecedorExists(fornecedor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fornecedor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OSC,Contato,Telefone")] Osc osc)
        {
            if (id != osc.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(osc);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OscExists(osc.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(osc));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Cpf,Telefone,Email,Nascimento,DataCadastro,Cep,Endereco,Numero,Complemento,Bairro,Cidade,Estado,Observacao")] Usuario usuario)
        {
            if (id != usuario.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuarioExists(usuario.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuario));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Data,Total,Status")] Recebimento recebimento)
        {
            if (id != recebimento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recebimento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecebimentoExists(recebimento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(recebimento));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Unidade,Quantidade,SaldoEstoque,ValorUnit,ValorTotal,Date")] Produto Produto)
        {
            if (id != Produto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Produto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdutoExists(Produto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(Produto));
        }
        public async Task UpdateAsync(Membro obj)
        {
            bool hasAny = await _context.Membro.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new NotFoundException("Voluntário não encontrado");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }