Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("LotId,LotNome")] Lotacao lotacao)
        {
            if (id != lotacao.LotId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lotacao);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LotacaoExists(lotacao.LotId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lotacao));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RazaoSocial,EmpEndereco,EmpEndNumero,EmpEndBairro,EmpEndCidade,EmpEndUF,EmpEndCEP,CNAE,InscricaoMunicipal,InscricaoEstadual,EmpresasId")] Filiais filiais)
        {
            if (id != filiais.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(filiais);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FiliaisExists(filiais.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmpresasId"] = new SelectList(_context.Empresas, "Id", "RazaoSocial", filiais.EmpresasId);
            return(View(filiais));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RazaoSocial,EmpEndereco,EmpEndNumero,EmpEndBairro,EmpEndCidade,EmpEndUF,EmpEndCEP,CNAE,InscricaoMunicipal,InscricaoEstadual")] Empresas empresas)
        {
            if (id != empresas.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(empresas);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmpresasExists(empresas.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(empresas));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("UsuId,Usuario,Senha,Email,Ativo,TipoUsuario")] Usuarios usuarios)
        {
            if (id != usuarios.UsuId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuarios);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuariosExists(usuarios.UsuId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuarios));
        }
Esempio n. 5
0
        public async Task UpdateAsync(Empresas obj)
        {
            bool hasAny = await _context.Empresas.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new NotFoundException("Id não encontrado! ");
            }

            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                throw new DbUpdateException("Erro de concorrência! " + e.Message);
            }
        }
Esempio n. 6
0
        public async Task UpddateAsync(Usuarios obj)
        {
            bool hasAny = await _context.Usuarios.AnyAsync(x => x.UsuId == obj.UsuId);

            if (!hasAny)
            {
                throw new NotFoundException("Id não encontrado");
            }

            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbConcurrencyException e)
            {
                throw new DbConcurrencyException("Erro de concorrência! " + e.Message);
            }
        }