Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Descricao")] Medicamento medicamento)
        {
            if (id != medicamento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicamento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicamentoExists(medicamento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicamento));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Idade,Nome,TipoAnimal,Raca,Observacoes,UsuarioId")] Animal animal)
        {
            if (id != animal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalExists(animal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UsuarioId"] = new SelectList(_context.Usuario, "Id", "Id", animal.UsuarioId);
            return(View(animal));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Telefone,Cidade,Endereco")] 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));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Resumo,Preco,MedicamentoId,ExameId")] Consulta consulta)
        {
            if (id != consulta.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consulta);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsultaExists(consulta.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(consulta));
        }
 public void Update(Consulta obj)
 {
     if (!_context.Consultas.Any(x => x.Id == obj.Id))
     {
         throw new NotFoundException("Id not Found");
     }
     try
     {
         _context.Update(obj);
         _context.SaveChanges();
     }
     catch (DbUpdateConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
Exemplo n.º 6
0
 public void Update(Veterinario obj)
 {
     if (!_context.Veterinarios.Any(x => x.Id == obj.Id))
     {
         throw new DllNotFoundException("Id not found");
     }
     try
     {
         _context.Update(obj);
         _context.SaveChanges();
     }
     catch (DbConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
        public async Task UpdateAsync(Caixa obj)
        {
            bool hasAny = await _context.Caixas.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new DllNotFoundException("Id not Found");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }