public async Task <IActionResult> GetInsuranceEndorsementLineById(Int64 InsuranceEndorsementLineId) { InsuranceEndorsementLine Items = new InsuranceEndorsementLine(); try { Items = await _context.InsuranceEndorsementLine.Where(q => q.InsuranceEndorsementLineId == InsuranceEndorsementLineId).FirstOrDefaultAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(Items))); }
public async Task <ActionResult <InsuranceEndorsementLine> > Insert([FromBody] InsuranceEndorsementLine _InsuranceEndorsementLine) { InsuranceEndorsementLine _InsuranceEndorsementLineq = new InsuranceEndorsementLine(); try { _InsuranceEndorsementLineq = _InsuranceEndorsementLine; _context.InsuranceEndorsementLine.Add(_InsuranceEndorsementLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(BadRequest($"Ocurrio un error:{ex.Message}")); } return(await Task.Run(() => Ok(_InsuranceEndorsementLineq))); }
public async Task <IActionResult> Delete([FromBody] InsuranceEndorsementLine _InsuranceEndorsementLine) { InsuranceEndorsementLine _InsuranceEndorsementLineq = new InsuranceEndorsementLine(); try { _InsuranceEndorsementLineq = _context.InsuranceEndorsementLine .Where(x => x.InsuranceEndorsementLineId == (Int64)_InsuranceEndorsementLine.InsuranceEndorsementLineId) .FirstOrDefault(); _context.InsuranceEndorsementLine.Remove(_InsuranceEndorsementLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_InsuranceEndorsementLineq))); }
public async Task <ActionResult <InsuranceEndorsementLine> > Update([FromBody] InsuranceEndorsementLine _InsuranceEndorsementLine) { InsuranceEndorsementLine _InsuranceEndorsementLineq = _InsuranceEndorsementLine; try { _InsuranceEndorsementLineq = await(from c in _context.InsuranceEndorsementLine .Where(q => q.InsuranceEndorsementLineId == _InsuranceEndorsementLine.InsuranceEndorsementLineId) select c ).FirstOrDefaultAsync(); _context.Entry(_InsuranceEndorsementLineq).CurrentValues.SetValues((_InsuranceEndorsementLine)); //_context.InsuranceEndorsementLine.Update(_InsuranceEndorsementLineq); await _context.SaveChangesAsync(); } catch (Exception ex) { _logger.LogError($"Ocurrio un error: { ex.ToString() }"); return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}"))); } return(await Task.Run(() => Ok(_InsuranceEndorsementLineq))); }