Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Descricao,PrecoCusto,PrecoVenda,Quantidade,Tipo")] Produtos produtos)
        {
            if (id != produtos.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(produtos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdutosExists(produtos.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(produtos));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Nome,Sobrenome,CPF,CNPJ,InscricaoEstadual,Email,Telefone,Celular,Endereco")] Clientes clientes)
        {
            if (id != clientes.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientesExists(clientes.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,RazaoSocial,CNPJ,InscricaoEstadual,NomeFantasia,Email,Telefone,Endereco")] Fornecedores fornecedores)
        {
            if (id != fornecedores.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fornecedores);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FornecedoresExists(fornecedores.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fornecedores));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,UserName,Senha")] Usuarios usuarios)
        {
            if (id != usuarios.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuarios);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuariosExists(usuarios.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuarios));
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Department department)
        {
            if (id != department.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(int id, [Bind("IdEscola,NomeEscola")] Models.Escola escola)
        {
            if (id != escola.IdEscola)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(escola);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EscolaExists(escola.IdEscola))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(escola));
        }
Beispiel #7
0
        public void Update(Seller seller)
        {
            if (!_context.Seller.Any(x => x.Id == seller.Id))
            {
                throw new NotFoundException("Not Found");
            }

            try
            {
                _context.Update(seller);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DBConcurrencyException(e.Message);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdAluno,NomeAluno,DataNascimento,IdEscola")] Aluno aluno)
        {
            if (id != aluno.IdAluno)
            {
                return(NotFound());
            }

            ViewData["IdEscola"] = new SelectList(_context.Escola, "IdEscola", "NomeEscola", aluno.IdEscola);

            if (ModelState.IsValid)
            {
                try
                {
                    if (aluno.Validar(this._context.Aluno.Where(a => a.IdAluno != aluno.IdAluno)))
                    {
                        _context.Update(aluno);
                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoExists(aluno.IdAluno))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Retorno = ex.Message;
                    return(View(aluno));
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aluno));
        }