public async Task <bool> StoreNewCreditNoteLineAsync(int CreditNoteId, CreditNoteLine CreditNoteLine) { CreditNoteLine.CreditNoteId = CreditNoteId; _context.CreditNoteLines.Add(CreditNoteLine); return((await _context.SaveChangesAsync()) > 0); }
public async Task <IActionResult> GetCreditNoteLineById(Int64 CreditNoteLineId) { CreditNoteLine Items = new CreditNoteLine(); try { Items = await _context.CreditNoteLine.Where(q => q.CreditNoteLineId == CreditNoteLineId).FirstOrDefaultAsync(); } 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(Items))); }
public async Task <ActionResult <CreditNoteLine> > Insert([FromBody] CreditNoteLine _CreditNoteLine) { CreditNoteLine _CreditNoteLineq = new CreditNoteLine(); try { _CreditNoteLineq = _CreditNoteLine; _context.CreditNoteLine.Add(_CreditNoteLineq); 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(_CreditNoteLineq))); }
public async Task <IActionResult> Delete([FromBody] CreditNoteLine _CreditNoteLine) { CreditNoteLine _CreditNoteLineq = new CreditNoteLine(); try { _CreditNoteLineq = _context.CreditNoteLine .Where(x => x.CreditNoteLineId == (Int64)_CreditNoteLine.CreditNoteLineId) .FirstOrDefault(); _context.CreditNoteLine.Remove(_CreditNoteLineq); 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(_CreditNoteLineq))); }
public async Task <ActionResult <CreditNoteLine> > Update([FromBody] CreditNoteLine _CreditNoteLine) { CreditNoteLine _CreditNoteLineq = _CreditNoteLine; try { _CreditNoteLineq = await(from c in _context.CreditNoteLine .Where(q => q.CreditNoteLineId == _CreditNoteLine.CreditNoteLineId) select c ).FirstOrDefaultAsync(); _context.Entry(_CreditNoteLineq).CurrentValues.SetValues((_CreditNoteLine)); //_context.CreditNoteLine.Update(_CreditNoteLineq); 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(_CreditNoteLineq))); }
public async Task <bool> DeleteCreditNoteLine(CreditNoteLine CreditNoteLine) { _context.Remove(CreditNoteLine); return((await _context.SaveChangesAsync()) > 0); }
public async Task <bool> UpdateCreditNoteLineAsync(int CreditNoteId, CreditNoteLine CreditNoteLine) { CreditNoteLine.CreditNoteId = CreditNoteId; return((await _context.SaveChangesAsync()) > 0); }