Exemple #1
0
        public async Task <Categoria> CriarCategoria(Categoria categoria)
        {
            if (categoria.CategoriaId == null)
            {
                _context.Categorias.Add(categoria);
            }
            else
            {
                _context.Update(categoria);
            }
            await _context.SaveChangesAsync();

            return(categoria);
        }
Exemple #2
0
        public async Task <ListaDesejo> RegistrarDesejo(ListaDesejo desejo)
        {
            if (desejo.DesejoId == null)
            {
                _context.Desejos.Add(desejo);
            }
            else
            {
                _context.Update(desejo);
            }
            await _context.SaveChangesAsync();

            return(desejo);
        }
        public async Task <FormaPagamento> CriarFormaPagamento(FormaPagamento forma)
        {
            if (forma.FormaId == null)
            {
                _context.Formas.Add(forma);
            }
            else
            {
                _context.Update(forma);
            }
            await _context.SaveChangesAsync();

            return(forma);
        }
Exemple #4
0
        public async Task <StatusCompra> CriarStatus(StatusCompra status)
        {
            if (status.StatusId == null)
            {
                _context.Status.Add(status);
            }
            else
            {
                _context.Update(status);
            }
            await _context.SaveChangesAsync();

            return(status);
        }
 public async Task Atualizar(Produto produto)
 {
     if (!_context.Produtos.Any(x => x.ProdutoId == produto.ProdutoId))
     {
         throw new NotFoundException("Produto não encontrado!");
     }
     try
     {
         _context.Update(produto);
         await _context.SaveChangesAsync();
     }
     catch (DbConcurrencyException e)
     {
         throw new DbConcurrencyException(e.Message);
     }
 }
        public async Task CadastrarConta(ContaCorrente conta)
        {
            await _controleContext.ContaCorrente.AddAsync(conta);

            await _controleContext.SaveChangesAsync();
        }
        public async Task GerarLancamento(Lancamento lancamento)
        {
            await _controleContext.Lancamento.AddAsync(lancamento);

            await _controleContext.SaveChangesAsync();
        }