public async Task UpdateAsync(Loja obj) { bool hasAny = await _context.Loja.AnyAsync(x => x.Id == obj.Id); try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task UpdateAsync(Compare compare) { bool hasAny = await _context.Compare.AnyAsync(x => x.Id == compare.Id); if (!hasAny) { throw new Exception("Id not found"); } try { _context.Update(compare); await _context.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task UpdateAsync(Produto produto) { bool hasAny = await _context.Produto.AnyAsync(x => x.Id == produto.Id); if (!hasAny) { throw new Exception("Id not found"); } try { _context.Update(produto); await _context.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Descricao,Slug")] Categoria categoria) { if (id != categoria.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categoria); await _context.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message); } } return(RedirectToAction(nameof(Index))); }