public ResultAndError <PedVentaLinea> Add(PedVentaLinea c) { ResultAndError <PedVentaLinea> result = new ResultAndError <PedVentaLinea>(); try { db.PedVentaLineas.Add(c); db.SaveChanges(); return(result.AddResult(c)); } catch (Exception e) { return(result.AddError(e, HttpStatusCode.InternalServerError)); } }
public bool DeleteMulti(IEnumerable <KeyValuePair <string, int> > PedVentaLineas) { List <PedVentaLinea> oAlbaran = new List <PedVentaLinea>(); foreach (KeyValuePair <string, int> PedVentaLineasNo in PedVentaLineas) { PedVentaLinea oPedVentaLineas = Get(PedVentaLineasNo.Key, PedVentaLineasNo.Value); if (oPedVentaLineas != null) { oAlbaran.Add(oPedVentaLineas); } } db.PedVentaLineas.RemoveRange(oAlbaran); db.SaveChanges(); return(true); }
public bool UpdateMulti(IEnumerable <PedVentaLinea> oPedVentaLineas, bool insertIfNoExists = false) { foreach (PedVentaLinea albaran in oPedVentaLineas) { PedVentaLinea old = Get(albaran.DocumentNo, albaran.LineNo); if (old == null && insertIfNoExists) { Add(albaran); } else { db.Entry(old).CurrentValues.SetValues(albaran); } } db.SaveChanges(); return(true); }
public ResultAndError <bool> UpdateReadingDate(IEnumerable <KeyValuePair <string, int> > pedventa, DateTimeOffset readingDate) { ResultAndError <bool> result = new ResultAndError <bool>(); try { foreach (KeyValuePair <string, int> no in pedventa) { PedVentaLinea oPedVentaLineas = Get(no.Key, no.Value); oPedVentaLineas.ReadingDate = readingDate; db.SaveChanges(); } return(result.AddResult(true)); } catch (Exception e) { return(result.AddError(e, HttpStatusCode.InternalServerError)); } }
public ResultAndError <bool> Delete(string documentNo, int lineNo) { ResultAndError <bool> result = new ResultAndError <bool>(); try { PedVentaLinea PedVentaLineas = Get(documentNo, lineNo); if (PedVentaLineas == null) { return(result.AddError("No se encontro el pedido venta linea con el documento " + documentNo)); } db.PedVentaLineas.Remove(PedVentaLineas); db.SaveChanges(); return(result.AddResult(true)); } catch (Exception e) { return(result.AddError(e, HttpStatusCode.InternalServerError)); } }
public ResultAndError <PedVentaLinea> Update(PedVentaLinea cr, bool insertIfNoExists = false) { ResultAndError <PedVentaLinea> result = new ResultAndError <PedVentaLinea>(); try { PedVentaLinea old = Get(cr.DocumentNo, cr.LineNo); if (old == null && insertIfNoExists) { return(Add(cr)); } db.Entry(old).CurrentValues.SetValues(cr); db.SaveChanges(); return(result.AddResult(cr)); } catch (Exception e) { return(result.AddError(e, HttpStatusCode.InternalServerError)); } }
public IActionResult UpdPedVentaLinea([FromBody] PedVentaLinea PedVentaLinea, bool insertIfNoExists = false) { return(Ok(pBS.Update(PedVentaLinea, insertIfNoExists))); }