public async Task <IActionResult> GetBoleto_SalById(Int64 clave_e) { Boleto_Sal Items = new Boleto_Sal(); try { Items = await _context.Boleto_Sal.Where(q => q.clave_e == clave_e).FirstOrDefaultAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(Ok(Items)); }
public async Task <ActionResult <Boleto_Sal> > Insert([FromBody] Boleto_Sal _Boleto_Sal) { Boleto_Sal _Boleto_Salq = new Boleto_Sal(); try { _Boleto_Salq = _Boleto_Sal; _context.Boleto_Sal.Add(_Boleto_Salq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(Ok(_Boleto_Salq)); }
public async Task <IActionResult> Delete([FromBody] Boleto_Sal _Boleto_Sal) { Boleto_Sal _Boleto_Salq = new Boleto_Sal(); try { _Boleto_Salq = _context.Boleto_Sal .Where(x => x.clave_e == (Int64)_Boleto_Sal.clave_e) .FirstOrDefault(); _context.Boleto_Sal.Remove(_Boleto_Salq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(Ok(_Boleto_Salq)); }
public async Task <ActionResult <Int64> > GetBoleto_SalCount() { // List<Boleto_Sal> Items = new List<Boleto_Sal>(); Boleto_Sal _Boleto_Sal = new Boleto_Sal(); Int64 Total = 0; try { // Items = await _context.Boleto_Sal.ToListAsync(); _Boleto_Sal = await _context.Boleto_Sal.FromSql("select count(clave_e) clave_e from Boleto_Sal ").FirstOrDefaultAsync(); Total = _Boleto_Sal.clave_e; } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } // int Count = Items.Count(); return(Ok(Total)); }
public async Task <ActionResult <Boleto_Sal> > Update([FromBody] Boleto_Sal _Boleto_Sal) { Boleto_Sal _Boleto_Salq = _Boleto_Sal; try { _Boleto_Salq = await(from c in _context.Boleto_Sal .Where(q => q.clave_e == _Boleto_Sal.clave_e) select c ).FirstOrDefaultAsync(); _context.Entry(_Boleto_Salq).CurrentValues.SetValues((_Boleto_Sal)); //_context.Boleto_Sal.Update(_Boleto_Salq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(Ok(_Boleto_Salq)); }