Пример #1
0
        public async Task <ActionResult <ContaBancaria> > Insert([FromBody] ContaBancaria conta)
        {
            MegaworksContext _context = new MegaworksContext();

            _context.ContaBancaria.Add(conta);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAll", new { id = conta.ContaId }, conta));
        }
Пример #2
0
        public async Task <ActionResult <ContaBancaria> > GetById(int id)
        {
            MegaworksContext _context = new MegaworksContext();

            var pagamento = await _context.ContaBancaria.FindAsync(id);

            if (pagamento == null)
            {
                return(NotFound());
            }

            return(pagamento);
        }
Пример #3
0
        public async Task <ActionResult <ContaBancaria> > Delete(int id)
        {
            MegaworksContext _context = new MegaworksContext();

            var conta = await _context.ContaBancaria.FindAsync(id);

            if (conta == null)
            {
                return(NotFound());
            }

            _context.ContaBancaria.Remove(conta);
            await _context.SaveChangesAsync();

            return(conta);
        }
Пример #4
0
        public async Task <IActionResult> Update(int id, [FromBody] ContaBancaria conta)
        {
            MegaworksContext _context = new MegaworksContext();

            if (id != conta.ContaId)
            {
                return(BadRequest());
            }

            _context.Entry(conta).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
Пример #5
0
        public async Task <ActionResult <IEnumerable <ContaBancaria> > > GetAll()
        {
            MegaworksContext _context = new MegaworksContext();

            return(await _context.ContaBancaria.ToListAsync());
        }
Пример #6
0
 public BaseRepository(MegaworksContext dbContext)
 {
     _dbContext = dbContext;
 }