public GuardarPagoResponse GuardarPago(Pago pago) { try { var tercero = _context.Terceros.Find(pago.Tercero.TerceroId); if (tercero == null) { _context.Terceros.Add(pago.Tercero); } pago.Tercero = tercero; _context.Pagos.Add(pago); _context.SaveChanges(); return(new GuardarPagoResponse(pago)); } catch (Exception e) { return(new GuardarPagoResponse("Ocurrieron algunos Errores:" + e.Message)); } }
public TerceroResponse GuardarTercero(Tercero tercero) { try { var terceroBuscado = context.Terceros.Find(tercero.Identificacion); if (terceroBuscado == null) { context.Terceros.Add(tercero); context.SaveChanges(); return(new TerceroResponse(tercero)); } return(new TerceroResponse("Error, la identificacion ingresada ya se encuentra registrada")); } catch (System.Exception ex) { return(new TerceroResponse("Se ha presentado la siguiente excepcion: " + ex.Message)); } }
public PagoResponse GuardarPago(Pago pago) { try { var terceroBuscado = context.Terceros.Find(pago.Tercero.Identificacion); if (terceroBuscado == null) { context.Terceros.Add(pago.Tercero); } else { pago.Tercero = terceroBuscado;//Tracking } context.Pagos.Add(pago); context.SaveChanges(); return(new PagoResponse(pago)); } catch (System.Exception ex) { return(new PagoResponse("Se ha presentado la siguiente excepcion: " + ex.Message)); } }